Things used in this project

Story

Introducing NCD’s Long Range IoT Industrial wireless vibration and temperature sensor, boasting up to a 2-mile range the use of a wi-fi mesh networking structure. Incorporating a precision 16-bit vibration and temperature sensor, this device transmits incredibly accurate vibration and temperature records at consumer-described durations.

For the duration of Power-Up, this vibration sensor learns “normal” base-line vibration from the monitored device. This base-line vibration is subtracted from regular sampled vibration readings to improve applicable vibration data. Preferably, the monitored device must be off even as the sensor is mastering. Once the sensor stabilizes and starts sending information, the device/equipment being monitored can be powered on. This business IoT wireless vibration sensor samples 3-axis of vibration data for 100ms after which calculate RMS, maximum, and minimal vibration readings. This sensor combines these records with temperature data in a data packet and transmits the result to modems and gateways in the wireless variety. Once the transmission is complete, the vibration sensor is going lower back to sleep, therefore minimizing power consumption.

Powered by using just 2 AA batteries and operational life of 500,000 wireless transmissions, a ten years battery life can be expected relying on environmental conditions and the data transmission interval. Optionally, this sensor may be externally powered, making it a perfect choice for wireless vibration monitoring device for industrial equipment. With an open communication protocol, this sensor transmits hardware-encrypted data that may be included with just about any control system or gateway. Data can be transmitted to a laptop, a raspberry pi, to Losant IoT cloud, Microsoft® azure® IoT, and an embedded gadget all at the equal time. Sensor parameters and wireless transmission settings can be modified using LabView® tracking software on a computer pc.

Long-Range Wireless Mesh Modem with USB Interface

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.

Resources Required

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 at particular value, an email alert will be sent to the respective email id.

if (msg.payload.temperature > 28) {   node.send({      topic: "Subject: System .... ",      payload: "Temperature:" + msg.payload.temperature,})}if (msg.payload.rms_x > 300) {   node.send({      topic: "Subject: System RMS_X value has been exceeded ",      payload: "RMS_X:" + msg.payload.rms_x,   });}      if (msg.payload.rms_y > 50) {   node.send({      topic: "Subject: System RMS_Y value has been exceeded ",      payload: "RMS_Y:" + msg.payload.rms_y,   });}   if (msg.payload.rms_z > 100) {   node.send({      topic: "Subject: System RMS_Z value has been exceeded ",      payload: "RMS_Z:" + msg.payload.rms_z,   });   }if (msg.payload.max_x > 500) {   node.send({      topic: "Subject: System MAX_X value has been exceeded ",      payload: "MAX_X:" + msg.payload.max_x,   });}if (msg.payload.max_y > 50) {   node.send({      topic: "Subject: System MAX_Y value has been exceeded ",      payload: "MAX_Y:" + msg.payload.max_y,   });}if (msg.payload.max_z > 0) {   node.send({      topic: "Subject: System RMS_x value has been exceeded ",      payload: "MAX_Z:" + msg.payload.max_z,   });}if (msg.payload.min_x < 0) {   node.send({      topic: "Subject: System MIN_X value has been exceeded ",      payload: "MIN_X:" + msg.payload.min_x,   });}if (msg.payload.min_y < 0) {   node.send({      topic: "Subject: System min_y value has been exceeded ",      payload: "MIN_Y:" + msg.payload.min_y,   });}if (msg.payload.min_z < (-150)) {   node.send({      topic: "Subject: System MIN_Z value has been exceeded ",      payload: "MIN_Z:" + msg.payload.rms_x,   });}   return;

You can edit values as our own.

Output

There is another method, in which you can send vibration and temperature emails separately.

The steps are the same up to function node

if (msg.payload.rms_x > 300 && msg.payload.rms_y > 50 && msg.payload.rms_z > 100 && msg.payload.max_x > 500 && msg.payload.max_y > 50 && msg.payload.max_z > 0 && msg.payload.min_x < 0 && msg.payload.min_y < 0 && msg.payload.min_z < -150) {    msg.topic = "Subject:System Vibration has been  exceeded.";    msg.payload = "Vibration: [rms_x:" + String(msg.payload.rms_x)+",rms_y:"+ String(msg.payload.rms_y)+",rms_z:"+ String(msg.payload.rms_z)+",max_x:"+ String(msg.payload.max_x)+",max_y:"+ String(msg.payload.max_y)+",max_z:"+ String(msg.payload.max_z)+",min_x:"+ String(msg.payload.min_x)+",min_y:"+ String(msg.payload.min_y)+",min_z:"+ String(msg.payload.min_z)+"]";    return msg;}

Now edit it like, you have done above.

Output

If you see no emails are sending or “sending failed," go to Google account and you’ll see security issue find.

If you still not getting emails, you can also check your spam folder.

Node-RED Flow

[{"id":"f8c5fd9c.087c9","type":"tab","label":"Flow 8","disabled":false,"info":""},{"id":"afeb6491.17a1a8","type":"ncd-gateway-node","z":"f8c5fd9c.087c9","name":"","connection":"fbb36648.bd10f8","x":130,"y":80,"wires":[["9d04b930.791128"]]},{"id":"aae4d5fb.e9e9b8","type":"ncd-wireless-node","z":"f8c5fd9c.087c9","name":"Vibration/Temperature","connection":"38428cea.affba4","config_comm":"4e4864b9.8d96ec","addr":"","sensor_type":"8","auto_config":true,"node_id":0,"delay":"900000","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":260,"wires":[["6b784ab9.c502f4","1b373014.106e7"]]},{"id":"9d04b930.791128","type":"debug","z":"f8c5fd9c.087c9","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":80,"wires":[]},{"id":"6b784ab9.c502f4","type":"debug","z":"f8c5fd9c.087c9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":330,"y":400,"wires":[]},{"id":"6ae18c2b.bcdfd4","type":"e-mail","z":"f8c5fd9c.087c9","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"jugranmanish2@gmail.com","dname":"email","x":710,"y":260,"wires":[]},{"id":"1b373014.106e7","type":"function","z":"f8c5fd9c.087c9","name":"Function","func":"if (msg.payload.temperature > 28) {\n   node.send({\n      topic: \"Subject: System .... \",\n      payload: \"Temperature:\" + msg.payload.temperature,})\n}\n\nif (msg.payload.rms_x > 300) {\n   node.send({\n      topic: \"Subject: System RMS_X value has been exceeded \",\n      payload: \"RMS_X:\" + msg.payload.rms_x,\n   });\n}   \n   \nif (msg.payload.rms_y > 50) {\n   node.send({\n      topic: \"Subject: System RMS_Y value has been exceeded \",\n      payload: \"RMS_Y:\" + msg.payload.rms_y,\n   });\n}   \nif (msg.payload.rms_z > 100) {\n   node.send({\n      topic: \"Subject: System RMS_Z value has been exceeded \",\n      payload: \"RMS_Z:\" + msg.payload.rms_z,\n   });   \n}\n\nif (msg.payload.max_x > 500) {\n   node.send({\n      topic: \"Subject: System MAX_X value has been exceeded \",\n      payload: \"MAX_X:\" + msg.payload.max_x,\n   });\n}\n\nif (msg.payload.max_y > 50) {\n   node.send({\n      topic: \"Subject: System MAX_Y value has been exceeded \",\n      payload: \"MAX_Y:\" + msg.payload.max_y,\n   });\n}\n\nif (msg.payload.max_z > 0) {\n   node.send({\n      topic: \"Subject: System RMS_x value has been exceeded \",\n      payload: \"MAX_Z:\" + msg.payload.max_z,\n   });\n}\n\nif (msg.payload.min_x < 0) {\n   node.send({\n      topic: \"Subject: System MIN_X value has been exceeded \",\n      payload: \"MIN_X:\" + msg.payload.min_x,\n   });\n}\n\nif (msg.payload.min_y < 0) {\n   node.send({\n      topic: \"Subject: System min_y value has been exceeded \",\n      payload: \"MIN_Y:\" + msg.payload.min_y,\n   });\n}\n\nif (msg.payload.min_z < (-150)) {\n   node.send({\n      topic: \"Subject: System MIN_Z value has been exceeded \",\n      payload: \"MIN_Z:\" + msg.payload.rms_x,\n   });\n}   \nreturn;","outputs":1,"noerr":0,"x":420,"y":260,"wires":[["6ae18c2b.bcdfd4"]]},{"id":"fbb36648.bd10f8","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false},{"id":"38428cea.affba4","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false},{"id":"4e4864b9.8d96ec","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false}]
[{"id":"f8c5fd9c.087c9","type":"tab","label":"Flow 8","disabled":false,"info":""},{"id":"afeb6491.17a1a8","type":"ncd-gateway-node","z":"f8c5fd9c.087c9","name":"","connection":"fbb36648.bd10f8","x":130,"y":80,"wires":[["9d04b930.791128"]]},{"id":"aae4d5fb.e9e9b8","type":"ncd-wireless-node","z":"f8c5fd9c.087c9","name":"Vibration/Temperature","connection":"38428cea.affba4","config_comm":"4e4864b9.8d96ec","addr":"","sensor_type":"8","auto_config":true,"node_id":0,"delay":"900000","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":260,"wires":[["6b784ab9.c502f4","5bc72290.6827bc","7857311.70715d"]]},{"id":"9d04b930.791128","type":"debug","z":"f8c5fd9c.087c9","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":80,"wires":[]},{"id":"6b784ab9.c502f4","type":"debug","z":"f8c5fd9c.087c9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":330,"y":400,"wires":[]},{"id":"7857311.70715d","type":"function","z":"f8c5fd9c.087c9","name":"Vibration","func":"if (msg.payload.rms_x > 300 && msg.payload.rms_y > 50 && msg.payload.rms_z > 100 && msg.payload.max_x > 500 && msg.payload.max_y > 50 && msg.payload.max_z > 0 && msg.payload.min_x < 0 && msg.payload.min_y < 0 && msg.payload.min_z < -150) {\n    msg.topic = \"Subject:System Vibration has been  exceeded.\";\n    msg.payload = \"Vibration: [rms_x:\" + String(msg.payload.rms_x)+\",rms_y:\"+ String(msg.payload.rms_y)+\",rms_z:\"+ String(msg.payload.rms_z)+\",max_x:\"+ String(msg.payload.max_x)+\",max_y:\"+ String(msg.payload.max_y)+\",max_z:\"+ String(msg.payload.max_z)+\",min_x:\"+ String(msg.payload.min_x)+\",min_y:\"+ String(msg.payload.min_y)+\",min_z:\"+ String(msg.payload.min_z)+\"]\";\n    return msg;\n}\n","outputs":1,"noerr":0,"x":420,"y":200,"wires":[["6ae18c2b.bcdfd4"]]},{"id":"5bc72290.6827bc","type":"function","z":"f8c5fd9c.087c9","name":"Temperature","func":"if(msg.payload.temperature>25)\n{\nmsg.topic = \"Subject:System temperature has been  exceeded.\";\nmsg.payload = \"Temperature:\" + String(msg.payload.temperature);\nreturn msg;\n}","outputs":1,"noerr":0,"x":430,"y":340,"wires":[["6ae18c2b.bcdfd4"]]},{"id":"6ae18c2b.bcdfd4","type":"e-mail","z":"f8c5fd9c.087c9","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"jugranmanish2@gmail.com","dname":"email","x":710,"y":260,"wires":[]},{"id":"fbb36648.bd10f8","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false},{"id":"38428cea.affba4","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false},{"id":"4e4864b9.8d96ec","type":"ncd-gateway-config","z":"","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"COM6","baudRate":"115200","pan_id":"7fff","rssi":false}]