Minimal MQTT with Micropython

Minimal MQTT with Micropython

I have been meaning to play around with MQTT for some time now, and finally decided to take the plunge one evening last week. I had three cheap home temperature and humidity sensors, and was bothered that they often didn’t agree. Surprisingly, while the analog one had a calibration adjustment in the back, I have no idea how to calibrate the two digital ones. I took this as a sign that it was time to learn MQTT and be able to install my own, accurate sensors. Of course, I began by ordering the cheapest sensors I could find, but I can always upgrade later on.


Three Cheap Sensors

While we have written quite a bit about MQTT in Hackaday, I had to go all the way back to 2016 to find this introductory four-part series by Elliot Williams. Five years is a long time in the tech world, but I decided to give it a try anyway.


Building a Broker


The first article worked perfectly, although instead of a Raspberry Pi, I used an old desktop that my wife was about to throw away. After wiping out Windows, doubling the RAM, and installing Debian, I had a new lab machine up and running. I installed the mosquitto packages from the standard repositories, and used them without issues to follow along with this article (I briefly tested on an Ubuntu and Mac machine, too). Installation is as easy as:


Debian and Ubuntu
sudo apt install mosquitto
sudo apt install mosquitto-clients

MacOS
brew install mosquitto

Networked Nodes


The trouble began with the second article. Elliot us ..

Support the originator by clicking the read the rest link below.