MQTT on MicroPython using Mosquitto

Sept. 15, 2019

Learn how to use MQTT with a Flask based backend running mosquitto on a Rasberry Pi and following up with a worker on an ESP8266 chip

micropython flask tutorial mqtt eclipse paho mosquitto

MQTT is the lightest form of messaging available out there. When designing my bookshelf, I chose to use MQTT over REST because I would not need to hardcode IP addresses, or attempt to register the nodemcus with a service discovery agent.

There were some initial setbacks with the setup, and in this article, I will cover the following:

  1. Running mosquitto on a Raspberry Pi
  2. Writing messages to mosquitto from Flask
  3. Reading messages from mosquitto in MicroPython
  4. Writing messages from mosquitto in MicroPython
  5. Reading messages from mosquitto in Python using paho-python
  6. Chaining things together.
  7. Tips and Tricks