--- title: "Reading and Visualising Modbus Data Using Node-RED and Thingsboard - icom OS Routers" slug: "reading-and-visualising-modbus-data-using-node-red-and-thingsboard-en" updated: 2025-10-09T08:11:27Z published: 2025-10-09T08:11:27Z canonical: "docs.insys-icom.com/reading-and-visualising-modbus-data-using-node-red-and-thingsboard-en" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.insys-icom.com/llms.txt > Use this file to discover all available pages before exploring further. # Reading and Visualising Modbus Data Using Node-RED and Thingsboard - icom OS Routers INSYS routers with icom OS provide an integrated Linux environment that is able to virtualise own, independent systems using Linux containers (LXC). This also makes it possible to run the graphical development tool **Node-RED** on the router for example in order to realise your own IoT applications. ## Situation You have a humidity/temperature sensor with Modbus RTU (RS485). You want to read out humidity and temperature using **Node-RED** and visualise the read values in a dashboard. We will use an open source IoT platform for this with [Thingsboard](https://demo.thingsboard.io/login). ## Solution Connect the sensor to the RS485 interface of your INSYS icom router (e. g. From the [ECR family](https://www.insys-icom.com/en/products/router-gateways/router/ecr-router/) or [MRX family](https://www.insys-icom.com/en/products/router-gateways/router/mrx-router/) with MRcard SI). Use the [Node-Red container](https://m3-container.net/#nodered) provided by us and install it to your router. Use it to create your application that reads the values from the sensor and make these values available to a Thingsboard dashboard then. ### Connecting the sensor to the router We have used a commercial humidity/temperature sensor with RS485 interface for this example. Connect the sensor to the power supply and RS485 interface of the router. Pay attention to the correct polarity of the connector for the RS485 data lines (refer to the [Installation manual](/kb/docs/ecr-info-en) of the router as well as the technical documentation of your sensor). > [!NOTE] > Please note! > > The RS485 data line son our routers are identified with D+ and D-. The designations TX+/RX+ (for D+) and TX-/RX- (for D-) are also common. If the designations A and B are used, these are not always clear, if no /- is appended. Often, A is used for D and B for D-, but this is not always consistent. If in doubt, the two wires would then have to be inverted once. ### Configuring the Internet connection of the router The router must have an internet connection in order to transmit the read data to Thingsboard. A startup wizard permits an easy configuration of the Internet connection. 1. Open the user interface of the router in a browser: https://insys.icom 2. Click in the *Wizards* → *Startup wizard* menu on START . 3. If necessary, change the time and synchronisation settings and click on NEXT . 4. Enter the desired authentication credentials and click on NEXT . 5. Configure the respective Internet connection and click on NEXT . 6. Configure your VPN connection (not necessary for this example) and click on NEXT . 7. If necessary, change the LAN connection settings (not necessary for this example) and click on NEXT . 8. If necessary, upload a configuration for the icom Router Management to the router (not necessary for this example). 9. Click on RUN WIZARD. 10. Observe the execution of the wizard and click on EXIT WIZARD. The startup wizard has configured the router for the Internet connection. You can follow the establishment of the WAN chain for the Internet connection in the *Status* → *Dashboard* menu in the *WAN chain* section. ![cg en nr startup 01](https://docs.insys-icom.de/assets/cg_en_nr_startup_01.png) ### Installing the Node-RED container to the router **Node-RED** is a graphical development tool that is executed in a container on the router. > [!NOTE] > Please note! > > In case an **icom Data Suite** is installed on your router, disable their container in the ![package variant closed](https://docs.insys-icom.de/assets/icons/package-variant-closed.png) *Container* → *Container* menu by disabling the *Active* checkbox and a click on SUBMIT. 1. Open the [INSYS Container page](https://m3-container.net/#nodered) and download the Node-RED container. 2. Open the user interface of the router in a browser: https://insys.icom 3. Click in the ![package variant closed](https://docs.insys-icom.de/assets/icons/package-variant-closed.png) *Container* → *Container* menu on and upload the container to the router. ![cg en nr install 01](https://docs.insys-icom.de/assets/cg_en_nr_install_01.png) 4. Click on SUBMIT. 5. Click on ![package variant closed plus](https://docs.insys-icom.de/assets/icons/package-variant-closed-plus.png) for the previously uploaded container and edit the container configuration: - *User group for CLI without authentication*: Read/Write - *Bridge to IP net*: net1 - *IPv4 address*: 192.168.1.10 / 24 - *Ipv4 gateway*: 192.168.1.1 6. Click on SUBMIT. ![cg en nr install 02](https://docs.insys-icom.de/assets/cg_en_nr_install_02.png) 7. Click on ACTIVATE PROFILE . ### Establishing the SSH connection to the container and preparing it The Node-RED container features Alpine Linux, which can be accessed via an SSH connection. 1. Connect to the container using a terminal program (such as PuTTY) via an SSH connection. - Address: 192.168.1.10 (or as specified above) - User name: root - Password: root ![cg de nr ssh 01](https://docs.insys-icom.de/assets/cg_de_nr_ssh_01.png) 2. Install the Python compiler and other tools to install the Modbus package in Node-RED in one of the next steps. To do this, enter the following commands in the command line (or shell): ```shell container1:~# apk add python3 container1:~# apk add make container1:~# apk add g++ container1:~# apk add gcc container1:~# apk add linux-headers ``` You have now prepared the container for the installation of the Modbus module in **Node-RED**. ### Installing the Modbus packet in Node-RED 1. Open the user interface of Node-RED under the address [http://192.168.1.10:1880](http://192.168.1.10:1880) (https is not supported!). ![cg en nr config 01](https://docs.insys-icom.de/assets/cg_en_nr_config_01.png) 2. Click on and select *Manage palette*. 3. Search on the *Install* tab for the **node-red-contrib-modbus** module and install it with a click on *Install*. ![cg en nr config 02](https://docs.insys-icom.de/assets/cg_en_nr_config_02.png) 4. Select to the *Nodes* tab and click on Close. ![cg en nr config 03](https://docs.insys-icom.de/assets/cg_en_nr_config_03.png) You have now installed the Modbus module in Node-RED and can continue with the development of your application. > [!NOTE] > Please note! > > After installing the Modbus module, you can remove the packages you just installed to reduce the size of the container. To do this, use the following commands via the SSH connection (refer to [Establishing the SSH connection to the container and preparing it](/kb/docs/reading-and-visualising-modbus-data-using-node-red-and-thingsboard-en#establishing-the-ssh-connection-to-the-container-and-preparing-it)): `container1:~# apk del python3` `container1:~# apk del make` `container1:~# apk del g++` `container1:~# apk del gcc` `container1:~# apk del linux-headers` ### Creating a flow in Node-RED A flow will now be created that reads data from the Modbus sensor and transmits this data to Thingsboard. Flow in Node-RED refers to the application defined by interconnected input, output and processing nodes. #### Creating a Modbus-Read node for the temperature sensor 1. Select a Modbus-Read node at the very bottom left and drag it onto the workspace. 2. Double-click the node to edit its properties on the *Settings* tab (the following settings apply to the sensor we use; refer to the documentation of your sensor for the appropriate values): - *Name*: TempSensor - *FC*: FC3: Read Holding Registers - *Address*: 00 - *Quantity*: 1 - *Poll Rate*: 10 second(s) ![cg en nr app 01](https://docs.insys-icom.de/assets/cg_en_nr_app_01.png) 3. Click behind *Server* on to add a new Modbus server and configure it: - *Name*: Sensor - *Type*: Serial - *Serial port*: /devices/1_serial1 > [!NOTE] > Router-specific path! > > This path applies to an ECR router; in case of an MRX with MRcard SI in slot 3, the path is **/devices/3_serial2** for example. - *Serial type*: RTU-BUFFERED - *Baud rate*: 9600 - *Queue logging*: > [!NOTE] > Please note! > > Activating *Queue logging* avoids collisions during reading in case several Modbus-Read nodes request data from the sensor. ![cg en nr app 02](https://docs.insys-icom.de/assets/cg_en_nr_app_02.png) 4. Click on Update. 5. Change to the *Optionals* tab and check the options *Show Activities* and *Show Errors*. ![cg en nr app 03](https://docs.insys-icom.de/assets/cg_en_nr_app_03.png) 6. Click on Done. #### Creating a function node for temperature conversion 1. Select a **function** function node and drag it onto the workspace. 2. Double-click the node to edit its properties on the *On Message* tab. 3. Copy the following code into the message window: ```shell var tempValue = msg.payload[0]/10; msg.payload = {"Temperature": tempValue}; return msg; ``` 1. Click on Done. ![cg en nr app 04](https://docs.insys-icom.de/assets/cg_en_nr_app_04.png) #### Connecting the nodes to a flow 1. Connect the two nodes by clicking on a connection point of one node and drawing a line to the other node. ![cg en nr app 05](https://docs.insys-icom.de/assets/cg_en_nr_app_05.png) #### Creating a Modbus-Read node for the humidity sensor 1. Add another Modbus-Read node and configure it: - *Name*: HuniditySensor - *FC*: FC3: Read Holding Registers - *Address*: 01 - *Quantity*: 1 - *Poll Rate*: 10 second(s) - *Server*: select the already added server **Sensor** ![cg en nr app 06](https://docs.insys-icom.de/assets/cg_en_nr_app_06.png) 2. Change to the *Optionals* tab and check the options *Show Activities* and *Show Errors*. 3. Click on Done. #### Creating a function node for temperature conversion 1. Add another function node **function** and configure it: ```shell var humidityValue = msg.payload[0]/10; msg.payload = {"Humidity": humidityValue}; return msg; ``` 1. Click on Done. 2. Connect the two nodes by clicking on a connection point of one node and drawing a line to the other node. #### Creating a debug node for checkng the values 1. Select a common **debug** node and drag it onto the workspace. 2. Double-click the node to edit its properties. 3. Select as *Output* **msg.payload** to output the message generated by the function nodes in a debug window of **Node-RED**. 4. Click on Done. ![cg en nr app 07](https://docs.insys-icom.de/assets/cg_en_nr_app_07.png) 5. Connect the outputs of the two function nodes to the input of the debug node. ![cg en nr app 08](https://docs.insys-icom.de/assets/cg_en_nr_app_08.png) #### Deploying the flow in the application and checking the function of the application 1. Click on Deploy in the top right corner of the title bar to deploy the flow. 2. Click in the right side bar on to open the *Debug* tab. ![cg en nr app 09](https://docs.insys-icom.de/assets/cg_en_nr_app_09.png) A green dot under the Modbus-Read nodes indicates the Modbus connection status. You can monitor the incoming values of the sensor for temperature and humidity in the debug window. ### Creating and configuring a Thingsboard account To be able to visualise read-out data using Thingsboard, a Thingsboard account is required. If a Thingsboard account does not yet exist, it must be created beforehand. Moreover, the device must be created in Thingsboard and an access token must be generated. 1. Open [Thingsboard](https://demo.thingsboard.io/login), set up an account if not already done and log in. 2. Change to the ![devices](https://docs.insys-icom.de/assets/icons/devices.png) *Devices* menu and click on *Add Device* → *Add new device*. ![cg en nr tb 01](https://docs.insys-icom.de/assets/cg_en_nr_tb_01.png) 3. Enter a suitable *name* for the device and click on *Next: Credentials*. ![cg en nr tb 02](https://docs.insys-icom.de/assets/cg_en_nr_tb_02.png) 4. Activate *Add credentials*, select **Access token** under *Credentials type* and enter a string under *Access token*. ![cg en nr tb 03](https://docs.insys-icom.de/assets/cg_en_nr_tb_03.png) 5. Click on **Add** (the third point, Customer, does not have to be configured). You have now created the router in Thingsboard and generated an access token. ### Setting up a connection from Node-RED to Thingsboard In order to transmit the values read out in **Node-RED** to **Thingsboard**, an MQTT output must be added to the Node-RED flow. 1. Add a network node **mqtt out** in the workspace and double-click it to edit its properties. 2. Click under *Server* on to configure the server connection on the *Connection* tab: - *Name*: ThingsboardConnection - *Server*: demo.thingsboard.io - *Port*: 1883 - *Connect automatically*: - *Protocol*: MQTT V3.1.1 - *Keep Alive*: 60 - *Use clean session*: ![cg en nr app 10](https://docs.insys-icom.de/assets/cg_en_nr_app_10.png) 3. Change to the *Security* tab, enter the access token specified in Thingsboard under *Username* and leave the *Password* empty. ![cg en nr app 11](https://docs.insys-icom.de/assets/cg_en_nr_app_11.png) 4. Click on Update. 5. Enter **v1/devices/me/telemetry** as *Topic* and a descriptive *Name*. ![cg en nr app 12](https://docs.insys-icom.de/assets/cg_en_nr_app_12.png) 6. Click on Done. Connect the outputs of the two function nodes to the input of the MQTT output node. 1. Click on Deploy in the top right corner of the title bar to deploy the flow. ![cg en nr app 13](https://docs.insys-icom.de/assets/cg_en_nr_app_13.png) A green dot under the MQTT output node indicates the MQTT connection status. ## Result testing 1. Click in Thingsboard into the row of your device and change to the *Latest telemetry* tab in the Device details. ![cg en nr tb 04](https://docs.insys-icom.de/assets/cg_en_nr_tb_04.png) You see the latest values transmitted from **Node-RED** to **Thingsboard** now. You can now visualise these in Thingsboard using widgets. ## FAQ - Why does the MQTT output node regularly lose its connection? When the MQTT output node is deployed, it connects for a short time, disconnects and reconnects. Try Modbus - Flex - Getter or Modbus - Flex - Write instead. - In which directory are the installed Node-RED modules located? The nodes are installed under the user directory of Node-RED. This is ~/.node-red/ by default. This directory contains your Node-RED settings file, flow files and the package.json file that lists all installed modules. - How can I save my flow with all the corresponding nodes? Click on and select *Export*. You can then download the desired flow in json format. - Why do I get regular timeout or CRC errors when reading out the Modbus values? If these errors occur more frequently, it may be because the serial port is being accessed from another source as well. Make sure that only the Node-RED container is accesses the serial port. Standard IP address: https://192.168.1.1; login depending on configuration; default for earlier firmware versions: *User name*: **insys**, *Password*: **icom**