Skip to the content.

Receive Device Environmental Sensor Data in Node-RED

Lab Objectives

In this lab you will build a flow that receives Device environmental temperature and humidity sensor data. You will learn:

Introduction

In just a few nodes, Node-RED can receive the data that was transmitted from the device over MQTT. This simple exercise will be the foundation for the next several sections that plot the data in a dashboard, trigger Real Time threshold alerts, store the data in Cloud Storage and allow for data analytics and anomaly detection.

MQTT Application Connections

In Part 2 you connected the ESP8266 application to a MQTT broker. In this section you will use a MQTT client in your Node-RED application.

Custom Certificates

If you have a custom server certificate configured on your MQTT broker, then you must use the SNI (Server Name Indication) extension to the TLS protocol to specify the server name in the connection parameters or Node-RED will not use your custom certificate.

Create the Node-RED Flow to Receive Device Events


IMPORTANT

The following step 1 helps you to configure a MQTT input node over a secure connection with your MQTT broker. If you are using non-secure connections, you will need to change the port (to 1883) and you will not need to fill authorisation-related fields.


Step 1 - Configure an MQTT Input in Node-RED

Step 2 - Extract the Temperature from the JSON Object

{ "d": {"temp":X, "humidity":Y }}

Step 3 - Node-RED Debug Nodes

Step 4 - Wire the Node-RED nodes together


Click to return to the Part 3 homepage.