MQTT / Node-Red and IoT

I have found a better idea for communication between my IoT devices. With a little research online I found out about IBM’s MQTT technology.

MQTT is really simple to implement for my current NodeMcu devices. In order to get the controller to do something, the devices can subscribe to a topic. Then when it receives a topic it can perform an action.

So for example instead of having a loop on the microcontroller to send the temperature every 10 seconds. I have set the microcontroller to subscribe to “/upstairs/room1/temp”. Now i have the Node-Red dashboard every 10 seconds send a “1” to that topic. Because the microcontroller is subscribed to it it can perform an action using for example an if statement if(payload[0] == ‘1’).

For my smart home I have chosen to do this, every 10 seconds Node-Red will send a 1 and the device will run a loop to collect the temperature and publish the results via MQTT.

When Node-Red collects this it simply shows the results on a webpage.

Leave a Reply

Your email address will not be published. Required fields are marked *