MQTT brokers are implemented on a large number of platforms: PCs, Raspberry Pi, Mainframes, etc. But now, thanks to Martin, it is as well available on an ESP8266!!!
This tiny chip can handle more than 100 pubs/subs per second according to my own measurements. So it fits perfectly for small and medium sized MQTT projects. So Martin did a splendid job with his stable and efficient development.
The broker does support:
- a subset of MQTT v3.1.1 (CONNECT, DISCONNECT, SUBSCRIBE, UNSUBSCRIBE, PUBLISH, PING)
- a smaller number of clients (at least 5 have been tested) based on the config of lwip
- up to 100 topic subscriptions
- arbitrary publications
- QoS level 0
The broker does not yet support:
- username, password authentication
- QoS levels other than 0
- non-clear sessions
- retained messages
I have installed the broker on the Hover-driven catamaran of my grandson and it can now be controlled by MQTT messages from a tablet or phone. Hardware and schematics are not changed, only stronger batteries with 18650-elements (3400 mAh) have been added.
You can see the old version with TCP server here:
The broker software and documentation are available here:
Further explanations are on youtube:
Because I did not need all the functions of the broker in my simple solution, the following ones are disabled: Scripting, NTP time service and remote console. So only the Accesspoint (address: 192.168.4.1) and the broker are active.
As MQTT client on the (Android) tablet the MQTT Dashboard is used. Because this client does not support sliders, the user interface is not that sexy, as on the TCP-version. But I will take a further look around. Two multi buttons with 4 choices each controls the direction, 0=left, ...100=straight, ... 200=right. A third multi button is for the speed, 0=zero ... 255=full speed. The battery voltage is monitored by a subscription, the broker publish every 10 seconds the battery status. After one hour with full speed, the voltage has been dropped from around 8 to 7 volts.
This solution is freestanding with an own WLAN (MyAp) and no connection to the home WLAN is necessary. The MQTT traffic of a short time period is shown in an attachement, sniffed by a PC nearby.
The development is performed with the Espressif-SDK using C language. A complete project including source and firmware is attached. For an easy usage, you can take just the firmware binaries and flash it into your ESP.
Have fun with your projects!
- Labs project
MQTT-Broker on ESP8266 and on Catamaran
October 2, 2017
Read the full post
- Complete project (3.36 MB )Complete project with C-source and firmware