Temperature sensor data visualisation with Node-RED: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| Line 30: | Line 30: | ||
[[File:Screen Shot 2022-04-13 at 5.53.02 am.png | 900px]] | [[File:Screen Shot 2022-04-13 at 5.53.02 am.png | 900px]] | ||
== Subscribing to MQTT == | |||
* To subscribe to MQTT we need the '''mqtt in'' node. | |||
* Find the mqtt in node and drag it onto the '''Flow 1''' | |||
* You will notice that the node has both a blue circle and a red triangle. | |||
* The red triangle indicates that the node requires further configuration before it will work | |||
[[File:Screen Shot 2022-04-13 at 6.13.51 am.png | 900px]] | |||
== Configuring the mqtt in node == | |||
* Double click on the mqtt in node. | |||
* In Properties > Server > select '''Add new mqtt-broker''' | |||
* Click on the '''Edit button''' to the right - which looks like a pencil | |||
[[File:Screen Shot 2022-04-13 at 6.19.00 am.png | 900px]] | |||
* Enter the following details: | |||
** Properties > Name > '''pycom-temperature-1''' | |||
** Connection > Server > '''au1.cloud.thethings.network''' | |||
** Connection > Port > '''1883''' | |||
** Leave all other details as shown in the example below. | |||
[[File:Screen Shot 2022-04-13 at 6.25.12 am.png | 900px]] | |||
Revision as of 20:26, 12 April 2022
Overview
This lesson assumes that a temperature sensor is sending data to The Things Network. In this lesson we will use the MQTT protocol to subscribe to data transmission events. We will create a program in Node-RED to subscribe to the data transmissions and to graph the data coming from the sensor using the in-built Dashboard function in Node-RED.
Learning Objectives
- Learn how to subscribe to a MQTT using the Node-RED MQTT-in node
- Learn how to extract specific sensor data using the Node-RED function node.
- Learn how to create a Dashboard in Node-RED to monitor live data.
Subscribe to MQTT
Open Node-RED
- Click on the Raspberry Pi main drop down menu.
- Select Programming > Node-RED
- Node-RED will automatically open the Terminal on the Raspberry Pi.
- It takes approximately ten seconds for Node-RED to initialise itself.
- To actually use Node-RED you need to open the web browser on the Raspberry Pi.
- Click on the default web browser.
- In the search bar enter localhost:1880
- Localhost is the address of the local or host machine.
- In this example the host address is 192.168.1.168, but your computer will have a different address.
- The number at the end of the URL (1880) is the port number for the Node-RED application.
- Different ports are assigned to different applications using HTTP protocols.
- Note - if you are using UFW (uncomplicated firewall) you may need to open this port otherwise Node-RED will not work.
Subscribing to MQTT
- To subscribe to MQTT we need the 'mqtt in node.
- Find the mqtt in node and drag it onto the Flow 1
- You will notice that the node has both a blue circle and a red triangle.
- The red triangle indicates that the node requires further configuration before it will work
Configuring the mqtt in node
- Double click on the mqtt in node.
- In Properties > Server > select Add new mqtt-broker
- Click on the Edit button to the right - which looks like a pencil
- Enter the following details:
- Properties > Name > pycom-temperature-1
- Connection > Server > au1.cloud.thethings.network
- Connection > Port > 1883
- Leave all other details as shown in the example below.
