All Collections
Connect your Devices
Manage your NCD industrial vibration sensors OTA remotely using Ubidots
Manage your NCD industrial vibration sensors OTA remotely using Ubidots

This is the second article on the Ubidots + NCD series. This one is about updating NCD's Industrial Vibration sensors remotely using Ubidots

Juan David Tangarife avatar
Written by Juan David Tangarife
Updated over a week ago

NCD devices offer their users a large variety of configurations such as the Ouput Data Rate (ODR), the Sampling Duration which determines the period that takes each measurement cycle, the Data Transmission Interval, among many others.

The user can easily change and configure these settings on industrial vibration sensor by launching the Node-RED embedded service, however, the user would need to be in the same local network as said device, or setting up a remote connection to such network from a different location.

In the following article, you'll learn how to set different parameters for your industrial vibration sensor by using Ubidots, giving you the ease to configure your NCD device from anywhere in the world thanks to Ubidots!

Requirements

Table of contents

1. Get the IoT Edge Computer IP address.

Please follow the first step of the following technical guide, once you know your device's IP address, proceed to the next step.

2. Import and setup the Node-RED flow into the NCD IoT Edge Computer.

In order to complete the following step, your NCD IoT Edge Computer needs to have installed Ubidots' MQTT nodes. Visit the following link in order to learn how to install said nodes to your IoT Edge Computer's Node-red.

It will be needed two different flows: one for managing the OTA remotely and another one for managing/reading the Sensor nodes accordingly.

The Node-RED flow developed by Ubidots team specifically for this implementation needs be imported, however, you cannot import it through the conventional Node-RED way because that would overwrite some nodes' IDs that must be fixed to certain values, otherwise, the flow would render useless. That is why the flow will be imported in the following way:

1. Use any URL shortener service of your preference for the following URL:

https://gist.githubusercontent.com/ubi-gists/25ab0e2ffeecfcfef6cd66d402fa214f/raw/e9d3d8bc6be0cab96ebb3baeb8f5b9801f11774b/NCD_Vibration_Sensors_OTA_flows.json

This article uses bitly, so the obtained URL looks like this:

https://bit.ly/3YuPja2

Copy this URL to a notepad because you'll have to manually write it in further steps.

2. Launch your preferred web browser and type the IoT Edge Computer IP address on the search bar. Then, click the Terminal option. This will take you to the IoT Edge Computer built-in shell.

When prompted for a username and a password, enter the default credentials:

  1. username: root

  2. password: ncdio

The EBDF will be different on your device, because this corresponds to the last 4 digits of your device's MAC address.

In order to "import" the Node-RED flow for this application, the .node-red/flows_NCDGateway-xxxx.json file needs to be replaced with the actual flow. To do so, run the following command, but first change the values as shown below:

  • <PATH>: This is path of the shortened URL previously obtained.

  • <Last4MAC>.json: Replace this with your IoT Edge Computer MAC address last 4 digits

curl 'https://bit.ly/<PATH>' -o ~/.node-red/flows_NCDGateway-<Last4MAC>.json -L

In this case, since the example URL obtained for this article is https://bit.ly/3YuPja2 and the device MAC address' last 4 digits are EBDF, then, the command to run is:

curl 'https://bit.ly/3YuPja2' -o ~/.node-red/flows_NCDGateway-EBDF.json -L

Wait until the download finishes and then restart the Node-RED service by running the following command:

/etc/init.d/nodered restart

Wait until the restart process finishes and launch Node-RED on the IoT Edge Computer by typing its IP address followed by :1880, on the search bar of your preferred web browser. I.e. if your device's IP address is 192.168.22.112, then you'll have to type 192.168.22.112:1880. After doing so, Node-RED will launch:

Go to the Data and Device Manager flow. Double click the ubidots_in node and set there your Ubidots Token.

On the same flow, go to the node named Assign Token here and double click on it, there, set your Ubidots Token on the field shown:

Now, go to the OTA Manager flow and search for the node named Subscribe to OTA variables and double click on it, then, set your Ubidots Token on the field shown:

3. Import the Dashboard

NCD IoT Edge Computer has three different operation modes, namely:

  • Processed data

  • Raw data

  • Processed + Raw On Demand

The application on Node-RED presented above, lets Ubidots users change between those operation modes, as well as other settings, in an easy way by Using a Manual Input Widget.

First, you'll need to manually create a few a variables on Ubidots for the NCD Node Sensor that you want to operate through the dashboard. Go to your device on Ubidots and create two raw variables with the names as follows:

  • OTA.

  • Request Raw

If you have more than one sensor nodes, you'd have to do this for each one.

Ubidots has a pre-built dashboard with all of the required elements that allow the user to operate the OTA parameters. To import said dashboard, run the following command on your PC replacing your Ubidots Token on the line X-Auth-Token:<YOUR-UBIDOTS-TOKEN>. I.e if your Ubidots Token is BBB-FFJJUkji, then, said line should be X-Auth-Token:BBB-FFJJUkji

curl -X POST 'https://industrial.api.ubidots.com/api/v2.0/dashboards/_/import_models/' \ 
-H 'X-Auth-Token:BBFF-IONay56PteRbxIMQbk4ppZ81VFX7yHGbZe5CTfmgEwZyqhbWnVbcVC9' \
-H 'Content-Type:application/json' \
-d '[ { "__model__": "dashboard", "label": "ncd-ota", "name": "NCD OTA", "description": "", "tags": [], "context": { "size": "auto", "alignment": "center", "isDynamic": true, "displayName": "name", "__customStyle": null, "dashboardType": "one-device", "defaultDevice": "~00:13:a2:00:41:ee:32:a8", "hasBackground": false, "imageSettings": { "isUrlValue": false }, "temporalxaxis": "dynamic", "filterSettings": {}, "hideDatePicker": false, "widgetsOpacity": 1, "floatingWidgets": false, "timestampFormat": "MM/DD/YYYY HH:mm", "deviceFilterType": "device_group", "deviceFilterEntityId": "~vibration-sensors", "widgetVerticalSpacing": 10, "hideHeaderFooterWidgets": false, "widgetHorizontalSpacing": 10, "prospector_is_filters_last_value_alt": false }, "timeframe": { "endDate": "now/d", "startDate": "now-7d" }, "isEditable": true, "order": 1 }, { "__model__": "widget", "name": "Request Raw", "position": { "h": 6, "w": 6, "x": 10, "y": 8 }, "type": "manual_input", "settings": { "time": [], "dataFetch": "inherit", "dataEntities": { "devices": [], "variables": [ { "span": null, "step": 1, "type": "last_value", "label": "request-raw", "maxValue": "1", "minValue": "1", "inputLabel": "Type in 1", "aggregationMethod": "last_value" } ] } }, "uxSettings": { "fontFamily": "Open Sans", "buttonLabel": "Request Raw Packet", "__customStyle": null } }, { "__model__": "widget", "name": "Device OTA", "position": { "h": 18, "w": 10, "x": 0, "y": 0 }, "type": "manual_input", "settings": { "time": [], "dataFetch": "inherit", "dataEntities": { "devices": [], "variables": [ { "span": null, "type": "context", "label": "ota", "contextKey": "output_data_rate_101", "inputLabel": "Output Data Rate (Hz) [50, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600]", "aggregationMethod": "last_value" }, { "span": null, "type": "context", "label": "ota", "contextKey": "sampling_duration_101", "inputLabel": "Sampling Duration [This number multiplies 50ms]", "aggregationMethod": "last_value" }, { "span": null, "type": "context", "label": "ota", "contextKey": "sampling_interval_101", "inputLabel": "Data Transmission Interval (minutes) [1, 5, 10, 15. 20, 30, 60, 120, 180]", "aggregationMethod": "last_value" }, { "span": null, "type": "context", "label": "ota", "contextKey": "mode_80", "inputLabel": "Raw or FFT (1,2) [1 = Raw, 2 = Processed+Raw on demand]", "aggregationMethod": "last_value" }, { "span": null, "type": "context", "label": "ota", "contextKey": "otaAllDevices", "inputLabel": "Global OTA", "aggregationMethod": "last_value" } ] } }, "uxSettings": { "fontFamily": "Open Sans", "buttonLabel": "Send OTA Command", "__customStyle": null } }, { "__model__": "widget", "name": "OTA Status", "position": { "h": 8, "w": 6, "x": 10, "y": 0 }, "type": "indicator", "settings": { "colors": [ { "color": "#effc2e", "range": 0, "message": "OTA request Sent" }, { "color": "#f27e07", "range": 1, "message": "OTA request received" }, { "color": "#038419", "range": "2", "message": "OTA performed" } ], "dataFetch": "inherit", "dataEntities": { "variables": [ { "span": "inherit", "color": { "a": 1, "b": 233, "g": 230, "r": 201 }, "label": "ota", "variableColor": { "a": 1, "b": 233, "g": 230, "r": 201 }, "aggregationMethod": "last_value" } ] }, "decimalPoints": null }, "uxSettings": { "dataFormat": "auto", "circleDesign": "large", "displayLabel": false, "__customStyle": null, "imageSettings": { "isUrlValue": false }, "timestampFormat": null } } ]'

After running the previous command, a new dashboard named NCD OTA will be created on your Ubidots account.


4. Change the IoT Edge Computer Settings from Ubidots

Go to the dashboard recently imported, you are going to change the IoT Edge Computer settings.

Let's say that you want to set the Sampling Duration to 500 ms, you can set that value directly from the recently created dashboard by setting the Sampling Duration value to 10, since this value gets multiplied by 50 ms.

Suppose that you want to set the Data Transmission Interval to 5 (meaning that the device will send the data each 5 minutes), you can then write the number "5" on the Data Transmission Interval field. Also, you can set the data mode by writing either 1 or 2 in the Raw or FFT field.

If you want the settings above to be applied to all of your NCD Sensor Nodes present in the Node-RED flow, you can set a "1" on the Global OTA field.

Lastly, Click the Send OTA Command button in order to set the current configured settings for the device selected.

After changing the device's settings and reloading the current window, the OTA Status Indicator Widget should be displayed with an orange color, meaning tha the OTA has not yet been updated and is queued for the next hour.

According to the way NCD designs its sensors, once a OTA parameter is changed, said changes will take effect in the 4th minute of the next hour, i.e if you make changes at 11:45, then those changes will take effect at some time around 12:04, if you make changes at 16:30, those changes will take effect at 17:04.

5. Feedback, suggestions and related articles.

Feel free to post questions or suggestions in our community portal, or contact us via support@ubidots.com.

Did this answer your question?