How we used Node-Red to test all sensors and Pi3 connection

For one of our smart home tests, we used Node-Red. It is available by default in the Raspberry PI operating system Raspbian. To access Node-Red the Raspberry PI and a smart device must be connected to the same network.

Node-Red is a visual development tool to wire together different types of Internet of Things devices, including Raspberry PI and its sensors.

To clarify, the tool allowed us to build flows using different nodes. Example from the prototype in Figure 11 for a single flow that triggers ‘ON & OFF’ function to turn LED on and off in the bathroom.

 

node-red-single-flow

Figure 11: Node-Red Single Flow

 

A node such as ‘BATHROOM’ which is responsible for a button as seen in Figure 12 and ‘PIN’ is the GPIO (General Purpose Input Output) on Raspberry PI that is responsible to turn led on or off.

Where further ‘PIR data’ using simple JavaScript, code turns the input/output (1/0) function into the text format and shows on the display if the led status is active or inactive as seen in Figure 12 on the right side of the image.

 

Figure 12: User Interface Dashboard

 

Another example of a more complicated flow is in Figure 13, where the node is responsible to collect and display measurements. The sensor that was used for this specific flow was DHT-11 (Temperature & Humidity) sensor, where further JavaScript code was added to separate temperature and humidity measurements. The software can read JavaScript and based on the code it displays on the device both humidity and temperature data in a chart or gauge.

 

Figure 13: Node-Red Temperature & Humidity Flow

 

To illustrate node ‘timestamp’ it has a task to send trigger every 30 sec to the sensor asking for the measurements. Below is an example of a ‘timestamp’ configuration panel.

 

Figure 14: Timestamp configuration panel

 

‘Temp’ node is responsible to receive a message from GPIO on a Raspberry Pi. The specific pin number 40 (GPIO21) on PI3 was chosen for the DHT11 sensor.

 

Figure 15: Temp configuration panel

 

‘TEMPERATURE’ function node in Figure 16 contains a simple JavaScript code that allows the sensor to understand what data is necessary to be demonstrated. The same applies to the ‘HUMIDITY’ function node.

 

Figure 16: TEMPERATURE function node

 

Once the DHT11 receives the necessary input function it can further deliver data and show on the gauge node. In gauge node properties ‘Value format’, ‘Units’, ‘Range’, and other options can be chosen to visually display the data on the application as seen in Appendix A.

 

Figure 23: Gauge node properties

 

Appendix A: Second-floor Temperature and Humidity measurements displayed on the gauge.

 

Similar options apply to the chart node properties, where the specific type of the chart and display options for the X-axis and Y-axis can be chosen with additional colors and time settings. The visual appearance on the chart can be seen in Appendix B.

 

Figure 17: Chart node properties

 

Appendix B: Chart of visual demonstration

 

In addition, to save data from the humidity and temperature measurements another JavaScript code was made. The code is displayed in Figure 18. It stores the data every 30 sec or every time when the sensor sends output function out to the Raspberry Pi.

The purpose of this function would be in case the electric power is lost, thus all data would be saved and within the next start, the data from the past would appear in a chart and gauge.

 

Figure 18: JavaScript code to save data

 

Nevertheless, of the above-mentioned benefits, the Node-Red also offers a powerful user interface interactive dashboard. The data or functions can be displayed on any device that has network access, including a personal computer, smartphones, and tablets.

To simply access the dashboard, the user types the address on the browser that usually ends with the port: 1880/ui, and to make access easier for mobile device users the website can be added to the home screen, which functions as an app seen in Figure 19 and Figure 20.

 

Figure 19: Application icon

 

Depending on the user needs the necessary function or process can be developed by programming languages and devices. Node-Red allows connecting any device (e.g. Apple, Android), as long as the device is connected to the wireless network.

 

Starlink Development offers a variety of examples that can be achieved within the IoT. Different options such as adding the smart voice assistants up to making different triggers such as when the outside temperature is below 20% the average, the heating indoors will increase to 22C.

 

We will be happy to talk to you to understand your company’s goals and requirements. Our free consultation will allow us to give advice about your processes and systems.

Starlink Development has become a partner for several companies. It all starts with just getting in touch with us.