Things used in this project

Story

Introducing NCD’s long-range wireless temperature humidity sensor, boasting up to a 28 Mile range using a wireless mesh networking architecture. Incorporating the Honeywell HIH9130 temperature humidity sensor transmits highly accurate temperature and humidity samples at user-defined intervals.

The on-board temperature sensor is rated for -25°C to 85°C or -13°F to 185°F and the humidity sensor is rated for 0 to 100% RH. It can be powered by just 2 AA batteries and an operational lifetime of 500, 000 wireless transmissions. Battery life can be extended up to 10 years depending on environmental conditions and the data transmission interval. Optionally, this sensor may be externally powered.

With an open communication protocol, this IoT wireless temperature humidity product can be integrated with just about any control system or gateway. Data can be transmitted to a PC, a Raspberry Pi, to Microsoft Azure® IoT, or Arduino. Sensor parameters and wireless transmission settings can be changed on the go using the open communication protocol providing maximum configurability depending on the intended application.

The long-range, price, accuracy, battery life and security features of Long Range Wireless Temperature Humidity Sensor make it an affordable choice which exceeds the requirements for most of the industrial as well as consumer market applications.

Setting up Node-RED

The sensor and Zigmo/Router come pre-programmed and work out of the box. In this section, we will set up a sensor and Zigmo link and start receiving data on our PC.

Steps to install Node-RED

Now that you have sensors running, we need a way to do something useful with that data.

Setting up the nodes

Assuming at this point you’ve started up Node-RED, you should be able to open a browser and navigate to http://localhost:1880, this will open up the flow builder that is the heart of the Node-RED experience.

Steps to build the flow

Finding your wireless sensors

Once you’ve added the node you’ll be able to view the info tab, which contains information about the node’s functionality, this tab is well-populated for most Node-RED packages and contains valuable information, many times you will not need to view any other documentation outside of the info tab, so keep it in mind while you are building your flows if you have a question about how a node works. The next thing we need to do is configure the node, when you first add it you’ll notice that there is a small triangle on the top right corner next to a blue dot, the triangle indicates that the node needs additional configuration, the blue dot indicates that the node has not yet been deployed as part of the flow.

Working with the data

Now out of your wireless sensors data is gathered and it is output to the “debug” tab, this “debug tab” is placed within the right sidebar subsequent to the information tab. To see the information are available in to hit the reset button. In Node-RED records is surpassed among nodes in a JSON packet. When the msg object comes into the debug tab you may make bigger it to view the overall list of information that comes with it. This is extraordinarily useful in case you need to quickly see which sensors are checking in. The other issue this node gives is an easy way to interchange your router to the network identity that devices in configuration mode document on, simply hit the button on the left of the node and the tool will switch to the configuration network, hit it once more to return it to listening mode. Once we get the wi-fi tool nodes set up, they may be set to routinely configure a sensor whilst it enters configuration mode, so it’s always available to maintain such gateway nodes present at the flow for speedy configuring a device.

Adding the wireless sensors

we need to separate wireless sensor records domestically in order that we are able to display it, we could use a switch node to split out the messages from the gateway based totally on the mac address with or sensor type, but as I referred to, the wireless nodes truly incorporate extra functionality for configuring the sensors, so we’ll start with them to give you an extra entire image of how those structures can work. In case you haven’t already seen packets coming in from both of your sensors, cross in advance and hit the reset button on the only that hasn’t stated. While a sensor assessment in thru any serial device configuration node, the mac address and kind of sensor is cached in a pool so we are able to quickly find it for the duration of this next step.

You’ll notice this automatically sets the sensor type for you, you can also give it a name to make it easier to identify. As noted in the info tab, the Serial Device for Config field is optional, and we won’t worry about it right now. The node you have just added effectively works as a filter on incoming sensor data, only passing through data for the mac address, or sensor type if no mac address is present.

Adding Function Nodes

The function node is used to run JavaScript code against the msg object. The function node accepts a msg object as input and can return 0 or more message objects as output. This message object must have a payload property (msg.payload) and usually has other properties depending on the proceeding nodes.

Here you have to write little javascript code to create a condition, so the temperature and humidity values will be written in the excel.

OUTPUT

Node-red_flow_json

[{"id":"c2697771.fb6db8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"2ecc9d14.42a2a2","type":"ncd-gateway-node","z":"c2697771.fb6db8","name":"","connection":"7cc0565b.898ba8","x":120,"y":80,"wires":[["f0354fde.82ef1"]]},{"id":"f0354fde.82ef1","type":"debug","z":"c2697771.fb6db8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":410,"y":80,"wires":[]},{"id":"176a6bea.9967a4","type":"ncd-wireless-node","z":"c2697771.fb6db8","name":"","connection":"3a63a78.66c7858","config_comm":"be3e53dd.346c8","addr":"","sensor_type":"1","auto_config":"","node_id":0,"delay":300,"destination":"0000FFFF","power":4,"retries":10,"pan_id":"7FFF","change_enabled":"","change_pr":"0","change_interval":"0","cm_calibration":"60.6","bp_altitude":"0","bp_pressure":"0","bp_temp_prec":"0","bp_press_prec":"0","amgt_accel":"0","amgt_mag":"0","amgt_gyro":"0","impact_accel":"0","impact_data_rate":"4","impact_threshold":25,"impact_duration":1,"activ_interr_x":1,"activ_interr_y":2,"activ_interr_z":4,"activ_interr_op":8,"filtering":0,"data_rate":5,"time_series":0,"reading_type":1,"x":120,"y":200,"wires":[["2b6528b9.6a3a78","390e7f7.e94e48"]]},{"id":"2b6528b9.6a3a78","type":"function","z":"c2697771.fb6db8","name":"","func":"var temperature = msg.payload.temperature\nvar humidity = msg.payload.humidity\nvar d = new Date();\nvar time = d.toLocaleTimeString();\nvar m ={'Time':time,'Temperature':temperature,'Humidity':humidity};\nreturn {payload:m};","outputs":1,"noerr":0,"x":350,"y":200,"wires":[["6d7bb397.bf6ddc"]]},{"id":"390e7f7.e94e48","type":"debug","z":"c2697771.fb6db8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":350,"y":340,"wires":[]},{"id":"6d7bb397.bf6ddc","type":"csv","z":"c2697771.fb6db8","name":"","sep":",","hdrin":true,"hdrout":"","multi":"one","ret":"\\n","temp":"Time,Temperature,Humidity","skip":"1","x":550,"y":200,"wires":[["4703fa10.7da934"]]},{"id":"4703fa10.7da934","type":"file","z":"c2697771.fb6db8","name":"excel_output","filename":"C:\\Users\\dcube\\Desktop\\excel_output.xlsx","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"utf8","x":730,"y":200,"wires":[[]]},{"id":"7cc0565b.898ba8","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false},{"id":"3a63a78.66c7858","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false},{"id":"be3e53dd.346c8","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false}]

Also, there is another way to send the data to excel by using “JSON” node and “excel” node.

Now the steps are the same up to adding the wireless sensor.

OUTPUT

But the limitation with excel node is that it overwrites the data in a single row.

Node-red Flow Excel node

[{"id":"21addc95.3322f4","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"df396104.3078b","type":"ncd-gateway-node","z":"21addc95.3322f4","name":"","connection":"b2933c2.fec5dc","x":140,"y":80,"wires":[[]]},{"id":"b938e310.ba4ef","type":"ncd-wireless-node","z":"21addc95.3322f4","name":"","connection":"220af376.1c24cc","config_comm":"fb46f24e.c4341","addr":"","sensor_type":"1","auto_config":"","node_id":0,"delay":300,"destination":"0000FFFF","power":4,"retries":10,"pan_id":"7FFF","change_enabled":"","change_pr":"0","change_interval":"0","cm_calibration":"60.6","bp_altitude":"0","bp_pressure":"0","bp_temp_prec":"0","bp_press_prec":"0","amgt_accel":"0","amgt_mag":"0","amgt_gyro":"0","impact_accel":"0","impact_data_rate":"4","impact_threshold":25,"impact_duration":1,"activ_interr_x":1,"activ_interr_y":2,"activ_interr_z":4,"activ_interr_op":8,"filtering":0,"data_rate":5,"time_series":0,"reading_type":1,"x":120,"y":200,"wires":[["169f12eb.2edaad","47ed6c99.4d9f54"]]},{"id":"169f12eb.2edaad","type":"json","z":"21addc95.3322f4","name":"","property":"payload","action":"obj","pretty":false,"x":350,"y":200,"wires":[["d98f712.f8b199"]]},{"id":"47ed6c99.4d9f54","type":"debug","z":"21addc95.3322f4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":300,"y":340,"wires":[]},{"id":"d98f712.f8b199","type":"excel","z":"21addc95.3322f4","name":"excel_output","file":"C:\\Users\\dcube\\Desktop\\excel_output.xlsx","x":550,"y":200,"wires":[[]]},{"id":"b2933c2.fec5dc","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false},{"id":"220af376.1c24cc","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false},{"id":"fb46f24e.c4341","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false}]