Michał Leśniewski's PicoMQTT Offers Performant MQTT Client, Broker Operation on ESP32, ESP8266 MCUs
New library is designed to put a low-cost, low-power microcontroller where a single-board computer would once have sat.
Developer Michał Leśniewski has released a library which aims to make it easier to use an Espressif ESP8266 or ESP32 microcontroller as an MQTT client or broker — and which offers support for handling thousands of messages per second.
"PicoMQTT is an MQTT library and can be used to set up both a client and a broker on the ESP8266 and ESP32. I know there are many other MQTT libraries out there," Leśniewski admits, "but only a few can be used to run a broker. I also tried to make it easy to use by providing an easy to use and intuitive API [Application Programming Interface]."
Typically, the MQTT messaging system is used to connect low-powered remote devices based on a microcontroller to a higher-performance central server. With energy prices continuing to climb in many parts of the world, though, some are looking to move the broker portion of the architecture to lower-powered hardware too — which is where PicoMQTT comes in.
PicoMQTT — which, despite its name suggesting compatibility with the Raspberry Pi Pico, is only compatible with Espressif's ESP8266 and ESP32 microcontrollers — offers both client and broker modes of MQTT 3.1.1, complete with support for arbitrary message sizing. It's designed for easy integration with the ArduinoJson
library, uses as little memory as possible, and can scale to thousands of messages per second on a low-cost ESP8266 device.
There are, however, a few limitations, focused around support for Quality of Service (QoS) flags. In client mode, PicoMQTT only supports QoS levels 0 and 1; in broker mode, it only supports level 0, while ignoring Will and Retained message types.
"it doesn't have all the features that Mosquitto [has] and it's much slower than a Raspberry [Pi]," Leśniewski admits. "Still, if all you have is just a few devices which don't send tons of messages, PicoMQTT should be sufficient. I was able to use the library for my IoT projects connecting a few ESPs and so far it was very stable."
PicoMQTT is available on the Arduino Library Manager now, with the source code published to GitHub under the reciprocal Lesser GNU General Public License 3.