Node-Red, MQTT and the new Weather Station (Part 2)


Node-Red is a browser based tool to let you quickly and easily construct your own logic of handling various IoT devices, including subscribing the MQTT messages, listening to HTTP requests, reading and writing to Databases, publishing to MQTT brokers and responding to HTTP requests. It also allows you to define specific functions written in JavaScript to provide complex logic operations, while using a visual, easy to use, drag-and-drop user interface to link different components and logic together.

Node-Red is a very light weighted run time built on top of Node.js, taking full advantage of its event-driven, non-blocking model of operation.

A typical Node-Red user interface

A typical Node-Red user interface

A Node-Red node is a function block which consists of at least one input, some internal logic, and zero or more output. Data is usually carried via the msg.payload though it can be carried by other properties under msg.

A node can also be configured to access to certain resources such as file from the file system, a database, MQTT messages, or the local hardware I/O, for example, I/O pins on a Raspberry Pi.

A typical Node-Red node

A typical Node-Red node, listening to a MQTT topic.

The hardware

The NodeMCU dev board is used to provide all the functionalities of a weather station including measuring the sun light, reading the temperature and relative humidity sensor readings, publishing to the MQTT broker the measure sensor values. It is designed so that it will wake up from deep sleep every 10 minutes to measure, connect and publish, then go back to deep sleep. According to the dev board manufacturer, it’s current in deep sleep mode uses only a few micro-Amps of current, ideal for batter operations like this one.

New Weather Station

New Weather Station

Cont. … Circult

Leave a Reply