PicoMQTT – An MQTT Client/Broker library for ESP8266 and ESP32

PicoMQTT is a lightweight MQTT library for Arduino/PlatformIO optimized for ESP8266 and ESP32. It not only supports the MQTT Client mode like most existing solutions but also the MQTT Broker mode which transforms an ESP8266 or ESP32 board into an MQTT gateway replacing a Raspberry Pi board or an IoT gateway typically used for this task.

The library follows MQTT 3.1.1 specification, supports the publishing and consuming of arbitrary-sized messages, can deliver thousands of messages per second, and supports easy integration with the ArduinoJson library to publish and consume JSON messages.

PicoMQTT ESP8266 MQTT Broker

MQTT Broker code example:


There are some limitations to the implementation due to constrained resources in the ESP8266 and ESP32, notably:

  • Client only supports MQTT QoS levels 0 and 1
  • Broker only supports MQTT QoS level 0, ignores will and retained messages.

Another downside highlighted by the developer is that only ESP8266 and ESP32 boards are supported.

Developer Micha Leniewski further told Hackster.io that PicoMQTT doesn’t have all the features that Mosquitto has and it’s much slower than a Raspberry Pi, but it’s good enough for a few devices that do not send a large number of messages. He found his own setup with a few ESP boards to be very stable. You’ll find the source code, documentation, and a benchmark sample on GitHub with everything licensed under GNU LGPLv3.

ESP8266 PicoMQTT Benchmark
PicoMQTT Benchmark with ESP8266

The benchmark consists of ESP boards in Broker mode, and a PC sending a flood of messages with different parameters. What’s really odd is that the ESP8266 can handle several thousand messages per second for small payloads (<=10 bytes) using up to 5 consumers, but the ESP32 struggles much more only being able to handle several hundred messages per second, or even less, under the same conditions.

ESP32 PicoMQTT Benchmark
PicoMQTT Benchmark with ESP32
Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

Radxa Orion O6 Armv9 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
9 Comments
oldest
newest
Boardcon CM3588 Rockchip RK3588 System-on-Module designed for AI and IoT applications