Now that you have a basic understanding of how to interact with the Intel® IoT Gateway. Let’s move on to adding some more sensor data and processing to the gateway. We will create Node-RED* flow to get data from temperature sensor and display it in the debug panel. We will be extending this flow to send data to the Microsoft Azure* IoT Hub later.

1. Attach the Grove* Temperature Sensor to the Grove Base Shield port A1 using one of the supplied cables.

2. In the Node-RED environment, create a new flow named Flow 3.

3. From the UPM_Sensors group in the nodes panel, drag a Grove Temperature Sensor into the visual editor for Flow 3. Then double click on the new node, and set the properties as follows. Click the OK button to save the changes:

Note: The interval of 10000ms really means the temperature will only update once every 10 seconds. You can speed that up by lowering the number to 5000ms or even 1000ms, but later when we are publishing data to Microsoft Azure*  it might be better to publish less frequently just to help reduce network traffic and resource utilization in Azure.

  • Name - Leave Blank
  • Platform - Firmata

  • Pin - A1

  • Unit - Celsius

  • Interval (ms) - 10000

4.  From the function group add a function node to Flow 3 and place it next it to the existing Temperature node as shown below. Double click on the new function node and complete the properites as follows. Click the OK button to save the changes:

Note: The purpose of this function is to provide the correct temperature when the sensor is being read with a 5V source. The Grove Temperature node assumes 3.3v by default.

  • Name - Data Conversion
  • Function - Use the following code

msg.payload = msg.payload * 3.3 / 5
return msg;

  • Outputs - 1

5. Connect the existing Grove Temperature node to the new Data Conversion function node by dragging a line from the square box on the right edge of the Grove Temperature node to the square box on the left edge of the Data Conversion node.

6. Add the following nodes, configure them as follows, and connect them as shown below:

Note: The Create Payload function creates the data payload that will eventually be sent up to the Azure IoT Hub.

From the function group, another function node.

  • Name - Create Payload
  • Function - Use the following code

var gateway = "IntelIoTGateway";return {
    payload: {
        deviceID: gateway,
        timestamp: new Date().toISOString(),
        temperature: msg.payload
  • Outputs 1

From the function group, add a json node. No configuration is necessary.

From the output group, add a debug node. No configuration is necessary.

7. Go ahead and deploy the new flow by clicking on the Deploy button in the top right corner of the Node-RED window:

8: Finally, we can test the new flow.

  • Ensure you are on the Flow 3 tab
  • Click on the Debug tab to view debug messages generated by the green msg.payload debug node.
  • Click the Trashcan icon at the top of the debug tab to clear any existing debug messages.
  • Watch for the debug messages to appear on the debug tab.
  • If you are not seeing debug messages, ensure that the msg.payload debug node has its debug messages enabled:
    • Debug messages are enabled, and will appear on the debug tab:

  • Debug messages are disabled, and no messages will appear on the debug tab.

Note: If you can't see the entire debug message on the debug tab, you can drag the splitter bar between the Visual Editor and debug tab panels to expand the view, or you can scroll to the right on the debug tab using the horizontal scroll bar at the bottom of it. Also, remember that the Grove Temperature node is only publishing a sensor value once every 10 seconds (10,000ms) so you need to wait at least that long to see anything appear.

Note: You can touch the temperature sensor (or blow on it) to see the value of the temp displayed change on the debug tab.


9. Ok, so seeing the debug messages is interesting, but it would be cooler if we could see the temperatures displayed on the LCD panel. To do that, from the UPM_Sensors, drag the Grove RGB LCD on to the Visual Editor as shown below, connect it to the output of the Data Conversion node, and configure it as follows:

Note: the RGB value is being set to green, and that means that when the temperature is displayed, the background color on the LCD panel will change to green for 1 second.

  • Name - Show the Temperature
  • Platform - Firmata

  • R - 0

  • G - 255

  • B - 0

  • Cursor Row - 1

  • Cursor Column - 0

10. Click the Deploy button to deploy the updated flow:

11. And now the LCD Panel should flash green, and update the display to show the current temperature on the second row of text.

12. If you are having problems with your flow, you can get a copy of a working version of the flow from the Node-RED Flows/Flow 3 - 01 - Temperature on LCD.json file in the lab files. To use it:


You should first delete the nodes you have by selecting them all, and pressing the Delete key on your keyboard.

You can tell that nodes are "selected" when they have an orange border:

Open the Node-RED Flows/Flow 3 - 01 - Temperature on LCD.json file in the code editor of your choice, and copy its contents to your computer's clipboard.

In the Node-RED editor, from the Hamburger button in the top right corner, select Import | Clipboard

In the Import nodes window, paste the json you copied, and then press OK.

Drag the newly imported nodes to where you want them in the Visual Editor