Table of Contents
Introduction
This article provides a comprehensive guide for configuring the general parameters of NCD sensors using the Node-RED visual programming tool and our NCD library. It details the step-by-step procedure for both the Enterprise IIoT Gateway and the Wireless Modem for receiving and managing sensor data. The process is intuitive and straightforward, but it addresses key points to ensure a satisfactory configuration outcome.
Requirements
To configure and acquire data from NCD sensors, an Enterprise IIoT Gateway or Industrial Wireless Modem (USB/Ethernet) is required. You can find links to these products in the following buttons.
If you are still unsure whether your application requires a Gateway or a Modem, you can find a comprehensive guide on the differences between these two devices below:
Overview
Our NCD library, “@ncd-io/node-red-enterprise-sensors” provides nodes for configuring NCD sensor parameters through a visual interface, including selection boxes, dropdown menus, and text inputs for values, among other features. When making these adjustments, the library communicates with field NCD sensors to apply the user-defined configurations. The NCD sensors receive these configurations, apply them, and report back to Node-RED to provide the status of each configuration.
As mentioned earlier, it is possible to configure the parameters of NCD sensors using either a Gateway or a Modem. The following images provide an overview of this process for each device.
NCD Enterprise IIoT Gateway
The Enterprise IIoT Gateway Lite, among many other features, includes the module for wireless communication with NCD sensors (up to 128 devices per gateway), as well as Node-RED and the pre-installed NCD library, all ready for use. This facilitates a faster deployment.
NCD Modem
The Wireless Modems (USB/Ethernet) feature a wireless communication module and a serial or Ethernet interface, and they only receive raw data from the sensors. A PC with Node-RED and the NCD library installed is required to begin the parameter configuration process, which may take a bit longer.
Node-RED
Node-RED, is a visual programming tool, It provides a browser-based editor that allows creating applications by wiring predefined black box functions (nodes) . Despite its technical nature, Node-RED offers a user-friendly interface. Node-RED is an open-source project under the OpenJS Foundation. This means it’s free to use, without any monthly subscription fees. You can install and run Node-RED locally on your PC, or, in the case of our Enterprise IIoT Gateway, it comes pre-installed and runs as a service.
NCD Enterprise Library
This library facilitates both communication with and configuration of the NCD Wireless Sensor Line. It includes “Wireless Gateway,” “Wireless Device,” and “ncd-gateway-config” nodes. The “Wireless Device” node is specifically designed to configure sensor parameters in an intuitive and graphical way.
If you’re using an IIoT Modem (USB or Ethernet) to configure NCD sensors from a PC, you need to install both Node-RED and the NCD Library manually. We will cover this process in the next steps.
Enterprise IIoT Gateway - Setup
Here you can find a complete Getting Started guide for setting up and accessing Node-RED from the Enterprise IIoT Gateway:
NCD First Flow
When you accessing Node-RED in the Enterprise IIoT Gateway, the first thing you will see is a basic flow containing two nodes: the “Wireless Gateway” node and the “Debug” node.
This is a preconfigured flow, meaning it is ready to receive data from the NCD sensors. When a new NCD sensor connects to the wireless network and sends data, the “Wireless Gateway” node automatically receives and processes the message. It then sends the message through its output terminal, and the message flows through the connection cable to the “Debug” node. This node receives the message and displays it in JSON format inside the “Debug” window on the right side of the Node-RED editor.
Below is a visual representation of the communication process and data flow for display within Node-RED. It illustrates the interaction between the NCD sensor and the Enterprise IIoT Gateway, demonstrating how data is transmitted from the sensor to the gateway and the flow of configuration commands from the Enterprise IIoT Gateway to the NCD sensor.
Industrial IoT Wireless to USB/Ethernet Modem - Setup
If you are using your own Gateway or Computer you will need a USB or Ethernet Modem, Install Node-Red, and Install the @ncd-io/node-red-enterprise-sensors library manually. The NCD USB Modem connects to the USB port or of your PC or Gateway, The NCD Ethernet Modem connects to your local area network and receives sensor data from NCD sensors. Use the NCD Modem for configuration of NCD long range wireless sensors.
Install Node-RED and NCD Library on PC
To perform the installation process of Node-RED on Windows operating system, you can follow the steps in these articles:
NCD First Flow
You need to make the necessary configurations in order to work with the Modem (USB or Ethernet), your PC and Node-RED. It is necessary to configure the “Wireless Gateway” node to specify the physical port through which the PC will communicate with the Industrial IoT Wireless Modem.
To configure this, follow these steps:
- Drag and drop the “Wireless Gateway” node into your Node-RED workspace.
- Double-click the node to access its properties.
- Click the “Add new NCD Gateway config node” button to configure the physical port that your PC will use to communicate with the modem.
The process is illustrated in the following GIF.
NCD configuration node
The Wireless Gateway node can be configured to communicate with both versions of the IIoT Wireless Modem. Each version requires its own specific configuration, as detailed below.
Serial connection
A serial connection is the simplest and most reliable connection to the wireless network. It doesn’t rely on any network layers like a TCP socket connection does.
TCP Socket Connection
A TCP socket connection allows the PC running Node-Red to be in an out of the way location while still receiving the sensor data from a Network Modem placed in a more central location. These communications heavily rely on the network that the Modem are on. It is recommended to put the PC and the Ethernet Modem on the same network or have an IT team to oversee the communications if this option is used.
Properties
1. Name
- This allows you to enter a human readable name for identifying this config node
- If no name is chosen it will default to the text for the Serial Port field
2. Modem Type
- This allows you to choose between USB (Serial) or TCP (Ethernet/Network)
- If you are using an USB Modem you will want to choose USB (Serial)
3. Serial Port
- Select the correct serial port that your USB Modem/Wireless Module is mounted to.
4. Baud Rate
- Do not choose anything other than 115200 unless you have changed the baud rate on the Modem/Module manually.
2. Modem Type
- This allows you to choose between USB (Serial) or TCP (Ethernet/Network)
- If you are using an Ethernet Modem you will want to use TCP (Ethernet/Network)
3. TCP Port
- Select the TCP Port that the modem is listening on
- The default TCP Port for our Ethernet Modems is 2101
4. IP Address
- The IP address of the Ethernet Modem on the network
- It is recommended to have the Ethernet Modem use a Static IP address so that this value never needs to change.
5. Network ID
- Network IDs allow you to have multiple groups of sensors, repeaters, and Gateway/Modems in a single area without interfering with each other
- The default value is 7FFF
- We do not recommend changing this value without specific purpose
- Make sure to change the Network ID of the sensors you want to be on this network BEFORE changing the Network ID here.
6. Add RSSI to incoming packets
- Selecting this box will add a signal strength indicator to all incoming comms
- Selecting this option will have a negative, but generally negligible effect on the Wireless Communication throughput
Once you have completed configuring the “Wireless Gateway” node, click the “Add” and “Done” buttons. Then you could add a debug node and connect it, in order to see the incoming messages. Finally, click the “Deploy” button to save and apply the changes.
If the configurations are correct and the “Wireless Gateway” node successfully establishes communication with the IIoT Wireless Modem, a message will appear in the “debug” window displaying the modem’s MAC address, as shown in the following image:
Below is a visual representation of the communication process and data flow for display within Node-RED. It illustrates the interaction between the NCD sensor and the NCD Wireless Modem, demonstrating how data is transmitted from the sensor to the modem and the flow of configuration commands from the Modem to the NCD sensor.
Connecting Your NCD Device to Gateway/Modem
The first step in configuring the parameters of NCD sensors is to establish communication between the NCD sensor and the Gateway or Modem. This communication is established automatically, with no user intervention required. The only prerequisites are to power on the NCD sensor (which is off by default) and ensure that the Gateway or Modem (USB/Ethernet) is powered.
Sensor Power Connectivity Options
Depending on the power option you selected when purchasing your NCD sensor, it may come with the option for battery power, external power, or both. Both options are illustrated below.
External Power Connector and Battery Power
Battery Powered Only
The power switch on this device has three positions:
- Battery Power
- Off
- External Power
The Battery Power position will use the onboard batteries to power the sensor and transmit data.
The Off position will power down all components of the sensor and no data will be transmitted
The External Power position will use the external power supply connected to the onboard barrel connector to power the sensor and transmit data.
The power switch on this device has two positions:
- On
- Off
The On position will use the onboard batteries to power the sensor and transmit data.
The Off position will power down all components of the sensor and no data will be transmitted
As soon as you power on the NCD sensor, it will automatically establish a connection with nearby DigiMesh devices. The following image illustrates this process for both the Gateway and the Modem; the connection is automatic.
RUN Message
As soon as the wireless connection between the NCD sensor and the Gateway or Modem is established, the NCD sensor automatically sends an initial packet, known as the RUN packet.
A RUN message received simply indicates that the sensor indicated in the msg.payload.mac is powered up and communicating with the wireless network. An example RUN message is showing in the next image:
{
"topic": "sensor_mode",
"payload": {
"mac": "00:13:a2:00:00:00:00:00",
"type": 1,
"nodeId": 0,
"mode": "RUN",
"lastHeard": 1721424191056
},
"time": 1721424191056,
"_msgid": "f41dad7923ece27c"
}
Sensor Data Message
Sensor data is the message that will come from a Wireless Gateway Node after RUN message. These messages can be discerned from other message types by the topic which will always be “sensor_data” to the right is an example of a Sensor Data message.
- nodeID
- A user configurable parameter allowing a user to input a simple id for a particular sensor
- firmware
- This identifies the firmware version of the sensor sending the packet
- battery
- The current voltage level of the batteries at the time of transmission
- battery_percent
- The current battery percent at the time of transmission
- counter
- The number of transmissions since boot or counter rollover
- sensor_type
- The machine identifiable type of the sensor
- sensor_data
- Object containing all sensor data related to the NCD sensor
- sensor_name
- Human Readable Sensor Type Identifier
- type
- An easily passed message type declaration
- addr
- The unique identifier of the sensor that transmitted the data
- received
- Epoch indicator of when the data was received by Node-Red
- original
- Auxiliary information on the packet and underlying protocol
- modem_mac
- The unique identifier of the Gateway/Modem that received the data
- Primarily used to tie locations/projects to sensors/sensor data
{
"topic": "sensor_data",
"payload": {
"nodeId": 0,
"firmware": 1,
"battery": "3.28",
"battery_percent": "98.56",
"counter": 1,
"sensor_type": 1,
"sensor_data": {
"variable_1": 0,
"variable_2": 0,
"variable_3": 0,
...
},
"sensor_name": "NCD Sensor ID",
"type": "sensor_data",
"addr": "00:13:a2:00:00:00:00:00",
"received": 1721424191583,
"original": {...},
"modem_mac": "00:13:A2:00:00:00:00:00"
},
"time": 1721424191584,
"_msgid": "d7f3341ef39225df"
}
These two packets, RUN and SENSOR_DATA, are the default basic data that each NCD sensor will send to the Gateway or Modem. Note that the RUN packet is sent only once each time a connection is established with the Gateway or Modem, while the SENSOR_DATA message is sent periodically and contains the measured field values and other data from the sensor. Once these two messages are received, you can be confident that you have a link with the sensor and can proceed with the configuration.
Wireless Device Node
Our NCD Node-Red library lets you configure any of NCD sensors easily using the “Wireless Device” node, simply by adjusting a few fields in your Node-RED flow and triggering a configuration update either through the RESET and CFG buttons on the sensor or waiting for a FLY message sent (we will explain this modes later in this article).
Begin the configuration process by dragging the “Wireless Device” node into the workspace. as shown in the following image:
Node Properties
You can edit a Wireless Device node properties by double clicking the node once it is placed in a flow.
Basic Properties
These configurations are responsible for configuring the Wireless Device node and how Node-RED should interact with NCD Sensors.
- Name
- Arbitrary name of this node
- Primarily used for easy identification in the flow
- Serial Device*
- The primary communication interface used to receive data from the sensor
- Clicking the edit icon will take you to a submenu to edit the particulars of the device chosen in the Serial Device dropdown
- To add a new configuration option you will want to choose “Add new ncd-gateway-config…” from this dropdown
- Serial Device for Config
- A secondary communication interface used to configure sensors without losing sensor data
- If no option is selected the communication interface selected under Serial Device will be used for configuration
- A second modem will be required to make full use of this option
- Mac Address
- Using this field allows you to choose a specific sensor that corresponds to this Wireless Device node
- Leaving this field blank allows any sensor of the type chosen under the Sensor Type field to correspond with this Wireless Device Node
- A search icon on the right can be clicked to search for Wireless Devices that the Serial Device has heard from to auto fill information for that device
- Sensor Type*
- This field limits the sensors that correspond to this Wireless Device node to a particular type of sensor
- Auto Config
- Checking the box next to this field tells Node-Red that the sensor(s) corresponding to this Wireless Device node should be configured when put into Configuration Mode manually
- OTF Config
- Checking the box next to this field AND having Auto Config checked tells Node-Red that the sensor(s) corresponding to this Wireless Device node should be configured when a FLY message is detected
*Required
Gateway Example
Modem USB Example
General Sensor Configuration
All NCD sensors share general sensor configurations, which are the basic settings that allow for the adjustment of certain operational parameters of the sensor. Additionally, each sensor may have its own specific configurations, such as calibration, stay-on mode, filtering, among others. For details on these specific configurations, please refer to the corresponding documentation. Below, each of these properties is outlined along with a description of each.
- Wait for Network Formation
- This option sends three commands to all local devices on the wireless network to help form the mesh network
- Destination Address
- This option will tell the sensor to ONLY send its data to a single receiver.
- By default the sensor sends data in Broadcast Mode.
- Network ID
- This option allows you to change the Network ID that the sensor will use to report its data while in RUN module
- You will need to make sure that a Gateway or Modem is configured to use this network ID in order to receive sensor data from it after configuration
- Node ID and Delay
- Node ID
- Node ID allows you to set an easy to understand unique ID for a particular sensor
- Delay
- Delay is the time in seconds between sensor data reading transmissions
- Node ID
- Power
- This option allows you to set the transmission power level of the sensor
- Retries
- Sets the maximum number of retries the sensor will attempt before considering a packet transmission failed
Destination Address - Transmission methods
Broadcast transmission
Broadcast means to transmit the same data to all nodes on a network. These transmissions are propagated throughout the entire network so that all possible nodes receive the transmission.
Unicast transmission
A unicast transmission consists of sending messages to a single node (Gateway or Modem) on the network that is identified by a unique 64-bit address.
Source: Broadcast gif
Source: Unicast gif
Save and Deploy
Once you have checked the box and configured the desired settings for the sensor, the next step is to click the “Done” button located at the top right. You might want to connect a debug node to the output of the “Wireless Device” node, in order to see the messages. Then, press the “Deploy” button to save and apply the changes.
Sensor Configuration Modes
Once this procedure has been completed, it is time to enable or wait for the configuration mode. Specifically, if the sensor features Automatic Configuration (OTF), no additional steps are required. The next time a message is received from the sensor, it will inquire whether any configuration needs to be applied through a FLY message. In this case, the gateway or modem will confirm if there are pending configurations and will automatically begin the configuration process. Conversely, if the sensor does not have the Automatic Configuration feature, it is necessary to manually set the sensor to configuration mode.
Manual Configuration
The manual mode is available on all NCD enterprise sensors. This configuration mode is enabled by the user, who must access the interior of the sensor (white box) by removing the four screws from the sensor cover.
Once you access the interior of the sensor, you will observe, among other components, two push buttons: one labeled RESET (RST) and the other labeled CONFIG (CFG). They appear as follows:
Sensors can be manually put into configuration mode by pressing and releasing the RESET button on the sensor and then immediately holding the CFG button on the sensor for 2-15 seconds.
PGM Packet
Once you set the sensor to configuration mode, it automatically sends a PGM packet to the Gateway or Modem. A PGM message received indicates that the sensor indicated in the msg.payload.mac has been put into configuration mode using the onboard buttons. An example structure of a PGM message is shown next image:
{
"topic": "sensor_mode",
"payload": {
"mac": "00:13:a2:00:00:00:00:00",
"type": 1,
"nodeId": 0,
"mode": "PGM",
"lastHeard": 1721424000999
},
"time": 1721424000999,
"_msgid": "36ac745134de68ee"
}
Once both the “Wireless Gateway” node and the NCD Sensor are enabled in configuration mode, the process of configuring the user-defined parameters will begin automatically. In the Debug tab, you will be able to see messages indicating the configuration process. An example of this process is shown in the following image:
Understanding Debug Messages
Pressing the “Wireless Gateway” node button to set the node to “Configuring” mode will automatically trigger the node to send a message “modem_mac” to the debug node, displaying its MAC address.
When placing the NCD Sensor into configuration mode by following the previously mentioned RESET and CFG button sequence, the sensor will transmit the PGM packet as described.
This action initiates the configuration process by the “Wireless Gateway” node. For each configured property, the NCD Sensor must send an ACK packet, indicating successful receipt of the configuration. Note that an ACK message is required for each configuration parameter set.
Finally, when the “Wireless Gateway” node has transmitted all configurations to the NCD Sensor, a “Config Results” message will appear, detailing the configured parameters.
Once the “Wireless Gateway” node is set to “Ready” mode, it will again send a message with its MAC address.
Pressing the RESET button on the NCD Sensor will return it to “Running” mode and it will send a DATA message.
Automatic Configuration
Some of the NCD Sensors supports configuration while in Run Mode. We call this configuration OTF or On the Fly. This configuration is initiated by a sensor_mode message from the Sensor with the mode of FLY. These messages are sent over the standard Run Mode wireless network so there is no need to change the Wireless Gateway nodes mode or manually manipulate the buttons on the sensor.
A FLY message indicates that the sensor is in RUN mode, but is entering a temporary state where it can be configured. Once the sensor sends a FLY message Node-RED has 2 seconds to respond with a configuration or extend this temporary configuration mode. If Node-RED has a “Wireless Device” node with Auto Config and OTF Config selected corresponding to the sensor that sent the FLY message then Node-RED will begin to configure that sensor. An example FLY message can be found on the right.
{
"topic": "sensor_mode",
"payload": {
"mac": "00:13:a2:00:00:00:00:00",
"type": 23,
"nodeId": 0,
"mode": "FLY",
"lastHeard": 1721424191766
},
"time": 1721424191767,
"_msgid": "5f6f01b6651b2f82"
}
This FLY message tells Node-Red that the sensor is ready for configuration changes. Node-Red has two seconds to respond with a configuration or extend this temporary configuration mode. An example of the automatic configuration process is shown in the following image:
Understanding OTF (Over-the-fly)
1. Sensor sends FLY message: This is now and indication that the sensor is checking if the modem wants the sensor to go into a temporary configuration mode. If no response is detected within ~2 seconds, then the sensor will go back to sleep as usual.
2. Gateway/Modem responds with a command This is the Gateway/Modem telling the sensor that it should go into configuration mode.
3. Sensor responds with an OTN package. This lets the gateway know that the sensor is in config mode and ready for config commands. The sensor will stay in this mode until ~60 seconds have passed OR the modem sends a command to end the configuration.
4. At this point the Gateway/Modem will send all of the configuration commands. For each configuration command the NCD Sensor respond with an ACK message.
5. Once all configurations have been made the Gateway/Modem will send other command. This tells the sensor to go to sleep and resume normal operation. You can see a “Config Results” message with the result of configurations.
6. The sensor responds with an OTF message This indicates to the modem that it is no longer accepting configuration commands.
The FLY message is the sensor letting Node-RED know that it is ready to enter OTF or On The Fly mode. If Node-RED is configured to make configuration changes through OTF mode then Node-RED will send a command to put the sensor into configuration mode and once the sensor is in configuration mode it will make all configured changes.
In essence it is an Over-The-Air configuration that doesn’t require manual manipulation of the sensor.
Config Results Message
This message will come from a ‘Wireless Device’ node when a sensor is configured. This message confirms whether the configurations were successfully made to the sensor or not. An example of the structure of this message is provided here:
{
...
"destination": true,
"id_and_delay": true,
"power": true,
"retries": true,
"activity_interrupt": true,
"config_exit_otn_mode_common": true
}
Summary
In this article, we provided a step-by-step guide for configuring the general settings of NCD sensors using the Enterprise IIoT Gateway or the Industrial Wireless Modem (USB/Ethernet) through Node-RED with the NCD library. We aimed to cover all necessary aspects for correctly configuring these parameters. As you observed, the process is quite straightforward and intuitive; you just need to pay attention and follow the steps according to the type of NCD sensor or Gateway/Modem you are using. We also covered the prerequisites and included a brief description of the messages or packets that the NCD sensor sends to Node-RED during normal operation and configuration mode.
Thank you, NCD Team