A transparent bridge from NCD wireless sensors to Ignition, with automatic device adoption


Greetings NCD users and builders!

I have seen quite a few posts about connecting NCD Wireless devices to Ignition in the past. There are many ways to accomplish this, some with more dependencies than others…

Recently I had the chance to tackle this myself and decided to create a script in Ignition that automatically “adopts” NCD devices through an HTTP endpoint. Bring a new device online, and it shows up in Ignition on its first message, with its own set of tags and no manual tag building.

A huge advantage of this approach is that it removes the need to define each device twice, once in Node-RED and then again in Ignition. The Wireless Gateway node already reports every sensor it hears, so a single flow covers all of them, and Ignition builds the tags on its own.

I’ve been calling this a transparent bridge to Ignition. Node-RED stays in the picture for decoding and sensor configuration, and every message passes through to Ignition exactly as the Wireless Gateway node produced it. Ignition never has to understand the raw wireless frames.

How it works

  1. The NCD Wireless Gateway node in Node-RED receives and decodes the sensor traffic, as usual.
  2. A small function node wraps each message so the topic travels with the payload.
  3. An http request node POSTs that JSON to a WebDev endpoint on the Ignition gateway.
  4. A project library script in Ignition reads the sensor’s MAC address from the message.
  5. If that MAC has never been seen, the script creates a device folder for it. Either way, it writes the incoming JSON into Document memory tags in that folder.

What you get in Ignition

[default]NCDdevices/
    00-13-A2-00-42-3C-83-00/     <- initial name is the MAC
        mac            (String)
        last_seen      (DateTime)
        sensor_data    (Document)
        sensor_mode    (Document)
  • sensor_data holds the latest data message: node ID, firmware, battery, counter, sensor type and the measured values.
  • sensor_mode holds the latest state message (RUN, PGM, FLY, ACK and so on).
  • mac is the device’s identity. The script matches on this tag, not the folder name, so you can rename the folder to something meaningful and data keeps landing in it.
  • Any other topic that carries a MAC gets its own Document tag automatically.

From there you can bind to the documents directly, or use expression or derived tags to pull out individual values for history and alarming.

Example expression, reading the ADC value from a device folder renamed to Influent_Flow:

jsonget({[default]NCDdevices/Influent_Flow/sensor_data}, "sensor_data.adc")

What you need

  • Ignition with the WebDev module
  • Node-RED with @ncd-io/node-red-enterprise-sensors
  • An NCD modem or gateway (I’m using the Ethernet modem over TCP)

Setup

Ignition

  1. Create a project library script named ncd/adoption and paste in the adoption script (available on request, see the end of this post).
  2. Create a WebDev Python resource at ncd/ingest and make its doPost a single line:
return ncd.adoption.ingest(request)

Node-RED

Wire the Wireless Gateway node into a function node:

msg.payload = { topic: msg.topic, payload: msg.payload };
msg.headers = { 'Content-Type': 'application/json' };
return msg;

Then wire that into an http request node set to POST, pointed at:

http://<ignition-host>:8088/system/webdev/<project>/ncd/ingest

Deploy, and watch the NCDdevices folder get created and fill with devices.

Things to know

  • Scripting: Ignition scripting is Jython 2.7, and the script is written for that.
  • Tag provider: the provider and root folder are settings at the top of the script. I’d suggest a dedicated tag provider for NCD devices to keep auto-created tags away from hand-built ones.
  • Security: the endpoint accepts any POST by default. Set the API key in the script (and send it as a header from Node-RED) or require authentication on the WebDev resource.
  • Configuration messages: PGM only shows up while the Wireless Gateway node is in configuration mode. “Config Results” comes from the Wireless Device node, so it needs its own wire to the endpoint if you want it in Ignition.
  • One connection: the Ethernet modem allows a single TCP client, so Node-RED owns that connection.

Where this could go

The longer-term idea is an Ignition module that talks to the modem directly, decodes the sensors, and handles configuration too, which would remove Node-RED from the path. That is a much bigger build. For now, this approach gets data flowing with very little setup, and it’s a great option if you already have an NCD gateway running Node-RED.

I can post the full script in a reply if anyone is interested in trying it out. Happy to answer questions, and I’d like to hear how others have approached this.
@Eduardo_Mtz @Bhaskar

2 Likes

Very nice. Thank you so much for sharing!

1 Like

@grant.chase-1229 Would you be interested in working with us to develop an Atrium App for Ignition? It’s on my todo list.

1 Like