Connect NCD IoT Sensors to the UbiDots Cloud

How to Send Sensor Data to UbiDots Cloud Service

So, you’ve received your IoT Sensor from NCD, and have installed the product. Now what? Once you have the physical Sensor installed, it’s time to start collecting data! We’ve partnered with the Cloud Service UbiDots to bring you the best experience possible. UbiDots is a high-level Cloud Platform with excellent customer service, and can be used with any Sensor in NCD’s Enterprise Line of Sensor devices. Check out our full Enterprise Sensor product line

NCD IoT Sensors can be used with an IoT Edge Computer Gateway Device (highly recommended) which receives data wirelessly, and sends this data to a Cloud Service (like UbiDots), and can also be sent via Ethernet, Wifi, or Cellular Network. The IoT Edge Gateway can support +/- 50 Sensors in one installation, depending on how often the sensors are set to report data. The IoT Edge Gateway runs the Node-Red program, which tells the Gateway what to do with the data it receives. Alternately, users do not have to use the IoT Edge Computer. NCD offers wireless modems, as well that can be used via USB, Ethernet, Wifi, RS45, and RS232. The modems receive information from wireless sensors and transfer the data to the user’s PC. Node-Red and NCD’s ncd-red-wireless library can then run on the user’s PC. 

Node-Red Interface is configured with a flow editor, and is preinstalled on the IoT Edge Computer. If the user is running Node-Red on a PC, Node-Red and the ncd-red-wireless library will need to be installed.

How to Send Sensor Data to UbiDots, IoT Sensors

Programming your IoT Sensor

Programming in Node-Red, IoT Sensors

In the NCD section, the user will grab a “Wireless Gateway” node  and drag in into the flow. Next, grab a “Debug” node, and connect that to the “Wireless Gateway” node. Now, time for configuration. Double click on the Wireless Gateway node to configure (for IoT Edge Computer users, this information will be preset.) To make a different selection, such as USB connection, choose that option, or whichever option suits the need best. Finally, click “Deploy” to get started. 

Powering on your IoT Sensor

Powering on Sensor

To power on the IoT Sensor, unscrew the lid, and locate the power switch. To power on, be sure the switch is toward the wall of the enclosure. Then, watch for transmissions in the “Debug” node. This can be done by clicking the “Bug” icon in the top right corner of the program. After which, readings will begin to appear!

Connecting to UbiDots

Connecting to UbiDots, IoT Sensors

To correctly connect to UbiDots, the user must install the UbiDots Library. To do so, click on the Menu Icon in the top right corner of the Node-Red Program>Manage Palate>Install and search for “UbiDots.” Locate the Ubidots/Node-Red Library, and then click “Install.” Scroll down on the left, and the user will now be able to see the UbiDots Nodes! At this point, the user will be looking for an “output” node, because we sending information OUT to UbiDots. Once the user has located said node, it can be drug into the flow. The data will need to be minorly altered, so the user can drag in a “function” node, and make slight modifications to the data coming from the sensor. Now, the user will connect the “Wireless” node to the input of the function, and the output of the function to the “UbiDots” node. Double-click the function node to edit the JavaScript that runs inside. By doing this, a new object is being created. The object is being sent as message.payload. This will be the data coming from the “Gateway” node. 

There also needs to be a variable labeled “UbiDots Device Label.” It will be set equal to message.payload.address. This will be the unique address for the wireless device. This means, it will create a device on UbiDotes with this unique label. (The name can be whatever you wish.) Next, set message.object.payload.temperature to message.payload.sensordata.temperature (for instance – it will depend on which IoT Sensor is being used and what data is being collected.)

Now, to observe the “object” being received from the IoT Sensor. This particular Sensor is detecting temperature and humidity inside the subject called “sensor data.” At this point, UbiDots is still unsure of what to do with the nested data. The humidity and temperature readings need to be dragged to the “upper level” in Node-Red, so this information is not nested below. After this information is moved, the nested information below may be deleted. Once this is complete, the new object that has been created can be sent out! The new object will come out of the “Function” node, and feed into the UbiDots node, so that it will be published to UbiDots. 

Configuring the UbiDots Node

Node-Red, IoT Sensors

At this point, the UbiDots node will need a name, such as “myubidotsaccount”, and a token needs to be created. Tokens are used to authenticate with UbiDots. To get started, sign into UbiDots, click on your avatar, and click on “API” credentials. It will expand and reveal some parameters, including “token.” Click on the “copy” field for the token, and paste in the box on the Node program (disable TLS). Click “done”, then click “deploy.” (Note: if there is an error message, or perhaps receiving data from another receiver, a “Switch” node may also be added to ensure the correct transmissions are being received from the preferred sensor.) Hit “deploy”, and errors will be eradicated. 

Go back to UbiDots and refresh the device page. Now, the sensor should be visible. After the sensor sends a transmission, press the reset button on the sensor to force a transmission. (If there are multiple shown, simply click on the sensor being used.) Data will now be displayed from the sensor, as well as the RSSI, or the signal strength to the computer, as well as the battery voltage for optimal performance.  

Customizing Data Transmissions

Customizing Data Transmissions, IoT Sensors

Once data is being received, the intervals at which information is transmitted can be customized. By default, NCD IoT Sensors report information every 10 minutes. To change this setting, the report interval of the Sensor will need to be changed. This can be done through Node-Red. Drag a “Wireless Device” node into the program, double click on it, set the serial device to “config” to the modem. Click the Mac search icon and find your sensor’s address in the list. Click on “auto config”, then click on “active” for Node ID and delay, and input a value for delay. This is the interval at which the sensor “wakes up” and sends readings (every 30 seconds, for instance.) Click “done” and click “deploy.” 

Now, the Gateway and Sensor need to be in configuration mode, and once this is done, the settings will be automatically applied. Click on the tiny square next to the “Wireless Gateway” node – this will put the Gateway into configuration mode. Now, the Sensor needs to be put into configuration mode. 

At this point, to configure the physical Sensor itself, the top of the sensor needs to be removed. Inside the Sensor, locate the reset button. Press and release the reset button. Then, press and hold the “C” button for approximately 8 seconds. Now, the Sensor is in configuration mode. Go back to the Node-Red program, and it will show that the sensor configuration is complete.  Take the Gateway out of configuration mode by pressing the small square next to the Wireless Gateway Node. Now, the Sensor needs to be taken out of configuration mode, and switched back to “ready.” Hit the reset button on the sensor again, and it will show in Node-Red that the Sensor is running, and transmitting data every 30 seconds as customized! 

Congratulations on connecting your NCD Wireless IoT Sensor to UbiDots. Happy data gathering!  

Play Video

Full Node-Red Flow File

[{"id":"cd6c7a263614b184","type":"tab","label":"Ubidots","disabled":false,"info":""},{"id":"285011d3b48d4ce2","type":"ncd-gateway-node","z":"cd6c7a263614b184","name":"","connection":"837142ce.132b28","unknown_devices":0,"outputs":1,"x":130,"y":160,"wires":[["9bbb9e20ef6d7de8","307fe030bc7a9b5b"]]},{"id":"9bbb9e20ef6d7de8","type":"debug","z":"cd6c7a263614b184","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":350,"y":160,"wires":[]},{"id":"82f4126be5931d3c","type":"ubidots_out","z":"cd6c7a263614b184","name":"My Ubidots Account","token":"BBFF-3562kP2uUTM7WfXn881rI4NGkVOoL8","label_device":"","device_label":"","tier":"business","tls_checkbox":false,"x":580,"y":240,"wires":[]},{"id":"3b4f20e6b76dcd1a","type":"function","z":"cd6c7a263614b184","name":"","func":"var newObj = {};\nnewObj.payload = msg.payload;\n\nnewObj.payload.ubidotsDeviceLabel = msg.payload.addr;\n\nfor(var key in msg.payload.sensor_data){\n newObj.payload[key] = msg.payload.sensor_data[key];\n}\n\ndelete newObj.sensor_data;\n\nreturn newObj;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":240,"wires":[["82f4126be5931d3c"]]},{"id":"307fe030bc7a9b5b","type":"switch","z":"cd6c7a263614b184","name":"","property":"payload.addr","propertyType":"msg","rules":[{"t":"eq","v":"00:13:a2:00:41:8c:31:66","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":230,"y":240,"wires":[["3b4f20e6b76dcd1a"]]},{"id":"837142ce.132b28","type":"ncd-gateway-config","name":"","comm_type":"serial","ip_address":"","tcp_port":"2101","port":"/dev/ttyS1","baudRate":"115200","pan_id":"7FFF","rssi":true}]