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 collect this it simply shows the results on a webpage.

Smart Home – The Idea

The idea is to monitor via several sensors the status of the house and to have some kind of control. We will also have a gesture sensor attached to a relay, we can then swipe to turn on and of the lights. The sensors will post their data to a MySQL server running on a raspberry pi 3.Read More