mqtt - wolfen351/public-micropython-iot-platform GitHub Wiki

Overview

The MQTT module provides functionality for connecting to an MQTT broker, publishing telemetry data, and subscribing to commands. It is designed to work with MicroPython and is used to enable IoT communication.

Features

  • MQTT client implementation for MicroPython.
  • Supports publishing telemetry data to a specified topic.
  • Subscribes to command topics and processes incoming commands.
  • Handles Last Will and Testament (LWT) for connection status.
  • Automatic reconnection and message retry on failure.
  • Configurable settings for server, topics, and credentials.

UI Hardware / Pinout Configuration

No specific hardware configuration is required for this module. It operates over a network connection.

Telemetry Provided

  • Device status (e.g., online/offline).
  • Custom telemetry data based on the application (e.g., temperature, humidity).

Telemetry Consumed

  • None directly consumed by the module. Telemetry is processed and published as needed.

Commands Provided

  • Subscribes to a command topic and processes incoming commands.
  • Supports firmware update commands via the iot-platform/version topic.

Commands Consumed

  • Commands received via the subscribed topic are processed and added to a command queue for further handling.

Additional Information

  • Settings Management: The module uses the MqttSettings class to manage configuration settings, which are stored in a file (mqtt.settings).
  • Web Interface: A web-based configuration page (web_mqtt.html) allows users to update MQTT settings such as server, topics, and enable/disable status.
  • Dependencies: Requires SerialLog for logging and network for Wi-Fi connectivity.
  • Error Handling: Implements robust error handling for connection issues and retries.
  • OTA Support: Checks for firmware updates and reboots the device if a newer version is available.