Node-RED control a heater
I design a flow chart using the temperature to control the heater on/off. The temperature coming from a DHT-22 sensor connecting to the internet through the MQTT protocol.

The Node-Red connect to the MQTT broker first, and then the temperature data will be formatted by a function node before logged into the mqtt.log file.

Another function node is sending MQTT topic to control a heater in the same room, (the heater is not existing in the physical world yet).

The new topic will send to the MQTT broker through the MQTT out node and return to this flowchart by the “heater” input node and logging in to the log file.