MQBoard - MicroPython microframework for managing MQTT
[Copy link]
This post was last edited by dcexpert on 2020-6-24 09:02
About the Author :
My projects are on the infrastructure side, with microcontrollers that work for a long time somewhere, sometimes a decade. At the same time, a lot of these projects are experimental in nature, and I keep tweaking them even after they are "deployed" and "in production". So I need a robust framework that allows me to remotely see what's happening on the board, sometimes perform interactive troubleshooting, and update software. And have high reliability, so that even if I make a mistake, I won't lose connection to the board or management rights. In this context, MQBoard is needed.
MQBoard contains the following:
- MQTT client library using the new uasyncio, handling disconnects and retransmissions, and supporting the data rates required for OTA upgrades (1.5MB transfers...)
- A set of python files to boot a board, provide safe mode on errors, log via MQTT, provide REPL access and launch modular applications
- An MQ REPL task that provides access to the flash file system, REPL and OTA and upgrades over MQTT
- Similar to pyboard.py file, plus OTA update, log viewing and file synchronization
- A simple blinky demo application
Right now MQBoard only works on esp32. I want to make it work on PYBD but don't have the time yet. It doesn't run on esp8266 because there is not enough memory.
All content
is designed for the following systems:
- Running in some remote location and need to be managed from remote, i.e. without plugging them into a USB port on some computer
- Use a single encrypted connection, specifically the MQTT connection to the broker.
By using a single connection, only one set of TLS buffers is required (20KB per connection!), and there are no certificates to maintain. There are also no open ports for attackers to target.
The above goals make the following features desirable:
- Everything must be designed to remain operational 24x7 and recover from failures.
- REPL Access: Ability to access the repl on the board over MQTT in order to run diagnostics, perform upgrades, or troubleshoot.
- OTA updates: Ability to send MicroPython firmware updates over MQTT.
- Modules: Ability to easily add or update functional modules with minimal impact on existing modules.
- Ideally, remote logging would be everything printed to a serial console via MQTT.
- Log the crash to some local persistent storage so that the crash can be analyzed remotely after a board reset.
- A watchdog timer and safe mode after consecutive crashes to ensure the board is always up and accessible via MQTT even if the application behaves abnormally.
Currently, all of these features are implemented, except for crash logging to local storage.
Issues
The main issue is low power operation. Power is not currently considered, and in particular boot time is not optimized to achieve periodic wake-up operation from the battery. OTA firmware upgrades and safe mode are not currently integrated, which means that OTA upgrades require more attention and thought than they should. The mqtt_async implementation attempts to be compatible with Peter Hinch's, and it is time to deprecate mqtt_as so that the board/mqtt.py functionality can be integrated directly , so that the management of Wifi can be separated.
Project Repository
|