Connecting Advantech ICR to Azure IoT using NodeRed

In the past, I have written about that perfect NodeRed node for Azure IoT. Using this node, you can connect to eg. Azure IoT and Azure IoT Central from any NodeRed solution.

I came across the Advantech ICR devices which offer cellular (4G) router connectivity in a ruggedized format and you can add your own custom logic:

You can either put C or Python apps on them and you also can use NodeRed on the V3 and V4 platforms.

Let’s dive into this NodeRed support and have an ICR connected to Azure:

ICR router

The router I use, an Advantech SmartStart, supports 4G over two sims and it supports WIFI next to the RJ-45 connection:

This ICR is a V3 device so it supports V3 abilities.

It has a console for configuring the device, including the ability to install Router apps:

Here, you see I already uploaded NodeRed. We will dive into that later on.

ICR Apps

Advantech offers a wide range of router apps for the ICR:

These apps work in conjunction with the standard available logic (like VPN, SSH, FTP).

Notice that the ability to use them is subject to the Router version (V2, V3, V4) and firmware version.

Eg. Docker support is a brand-new feature but only applicable for certain devices:

NodeRed support

We are interested in NodeRed support.

There is a manual available with detailed information.

In this blog post, we follow the steps of both installing a predefined node and a custom node.

First, we need to install both the NodeJS router app and the NodeRed router app:

Just download the V3 or V4 TGZ files (depending on the ICR model) and install them using the wizard:

Once installed, the apps are added to the list:

Open the NodeRed link and navigate to the service page:

As you can see, there are a number of settings yo can configure:

  • Enable Automatic start. This setting can be used to stop and (re-)start the NodeRed service
  • Enable flow Webeditor. You can save memory space on the device by disabling the UI.
  • The default NodeRed UI port is 1880. Change it only if needed
  • You can drop a custom flow on that folder on the device. Default location is /var/data/node-red (demonstrated later on)
  • You can also add static web files (out of scope)

Once the service is started, you can follow the progress of starting up the NodeRed service on the Log page. It will take approx. thirty seconds for NodeRed to start up.

Once the app is up and running, navigate to the NodeRed editor using the Flows link:

To login into NodeRed, use the same credentials as used for the router admin.

NodeRed ICR router nodes

A default set of nodes is already available. See the documentation for a specific list of all available nodes.

By default, Advantech has provided also these extra nodes for interaction with the router itself. These are those extra nodes:

It depends on the ICR model you have if those nodes will work. Sending an SMS will work with all cellular models. My SmartStart has no User LED so the ‘signal led’ must be ignored for my model.

See the documentation for details.

The NodeRed instance does NOT support the palette for installing extra modules:

So, there are two ways to still add extra nodes:

  1. Picking selected nodes (made available by Advantech) from the Router app list website
  2. Adding custom nodes to a specific folder on the router OS by hand

We will check out both solutions.

Adding a router app node

The easiest way to add other nodes is to make use of the router app selection.

The following list of nodes is currently offered by Advantech:

See the documentation for examples on how to use these nodes.

I added two of them (OPC-UA and Modbus) by, again, just downloading the appropriate TGZ files and uploading them to the router:

After restarting the NodeRed service, the nodes are made available for usage:

If you would like to see other NodeRed nodes made available as Router Apps, please contact Advantech (contact information is provided in their documentation).

Adding a custom node

Adding other nodes is a bit harder.

There are two kinds of nodes:

  1. Nodes which are a combination of both Javascript/NodeJS and C libraries
  2. Nodes which are completely written in Javascript/NodeJS

The first kind of node needs to be compiled towards the processor/OS on which it has to be executed. This is out of scope for this blog post.

The second kind of node is not that hard to add, it just works if you follow the right, simple steps.

The steps involved are:

  1. Get your hands on the source code of the node.
  2. Add dependencies using NPM
  3. Enable FTP on the ICR
  4. Copy the files over to a specific folder on the ICR
  5. Disable FTP
  6. Restart NodeRed

This is demonstrated below.

Adding the Azure IoT node

First, we download/clone the latest source code of the Azure IoT node we want to deploy.

The actual source code of the node is seen in the ‘AzureIoTDevice’ folder. But we are interested in the ‘package.json’:

That file describes all libraries needed to run this node.

Using NPM, we can retrieve and install the node module dependencies:

npm install .

This is approx. 15Mb of logic.

The node is now ready to be transferred to the ICR.

So, enable FTP on the router:

Once enabled, we can forward almost the complete directory into the ICR location:

Notice that I created this ‘/azureiotdevice’ folder in the subfolder which I found in the documentation:

Now, you only have to disable FTP again (to protect your device) and again restart the NodeRed service.

Check NodeRed, a new Azure IoT device node should be added:

From there, just follow the Azure IoT device node documentation on how to connect this node to Azure IoT or Azure IoT Central.

Bonus: Custom flows

The flows of your NodeRed instance are stored in ‘/var/data/node-red’ as seen in the configuration.

There, the flows are stored in a file named ‘flows.json’.

You can eg. replace it with the Azure IoT node flow example seen here. Just copy that file (using FTP) to the location and rename it. This gave me the flow as seen below.

Sending Modbus telemetry to Azure

To demonstrate this works, I will send some telemetry coming from an Advantech Wise 4012E using the Modbus protocol:

This is the flow I use:

This example is based on the default Azure IoT example where I added the Modbus input node and extended the telemetry message with the two coil values coming from the two switches on the Wise module:

I connected the Azure IoT device node to an Azure IoT Hub device registration and after publishing the flow, both Modbus connection and Azure IoT device connections become active and messages are sent:

Using the Azure IoT Explorer, we see the telemetry arriving in the Azure IoT Hub:


Yes, the Advantech ICR can help you with your specific Azure IoT projects.

When you only need some simple logic, you do not need to introduce expensive devices next to the connectivity device.

With the combination of NodeRed and the Azure IoT Node, this ICR solution could even be certified for Azure IoT and Azure IoT Central.

If you need more control, you could research the use of native Phyton applications, including support for the Azure IoT device SDK for Phyton:

The NodeRed flow is available here. Please fill in your own IoT Hub hostname and Device SAS key.

Disclaimer: I have been granted this loaner hardware by Advantech to be able to write this blog post. Advantech was not involved regarding the content prior to publication.


4 gedachten over “Connecting Advantech ICR to Azure IoT using NodeRed

      1. Hi Sander, thank for the quick reply. Can you please send me the flow. I need more the function around the Azure Node. I will change the modbus Stuff and send you the link to my blog post 😉

Reacties zijn gesloten.