
Recently I noticed a few visitors to this site were searching for information on MTConnect support in Node-RED.
I’ve never used Node-RED before, but thought this would be a good reason to take a first look at it.
What’s Node-RED?
Originally developed by IBM, and released as open source software in 2016, Node-RED is (to quote its website) “a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.”
Node-RED allows you to describe IoT hardware, online services, databases, and other APIs as nodes, which can be connected and laid out into a “flow” that performs useful actions.
Installation is easy — a one-liner on the command line if you already have NodeJS and NPM.
Its browser interface is a drag-and-drop “visual” paradigm that, depending on your background, might vaguely remind you of VSCode, ladder logic coding, Scratch programming language, flowcharts, or even HyperCard.
Once deployed to the Node-RED server, each “flow” will perform whatever actions were visually laid out in the browser.
Flows can easily be exported to JSON, making them easy to share and move from server to server.
How does it work with MTConnect?
Node-RED is meant to automate flows that include online services, and hey, MTConnect is an online service.
After walking through two tutorials on the Node-RED website, I tried to create a basic flow: when triggered, send a request to an MTConnect agent for current
data, then process the resulting XML.

The trigger was an “inject” node. The HTTP request was an “http request” node, configured to request https://smstestbed.nist.gov/vds/current
. Next came an “xml” node, which processes boring old XML into more easily consumable JSON.

From there, getting header data (such as timestamp and next sequence number) and the device streams data was a matter of processing the JSON using Javascript. Easy.
What Next?
This is the most basic example possible. A real solution for MTConnect would include handling error messages from the server, and of course, doing something useful with the MTConnect data.
Since MTConnect is HTTP-based, processing errors would mean adding “switch” nodes to handle HTTP error codes, and to handle cases when the MTConnectAgent returns an error document.
Doing something useful with the MTConnect data would mean some sort of output. This might happen through websockets, TCP, HTTP, or by linking to another flow that handles the hard work of doing something.
Although Node-RED “inject” nodes can be set up to periodically fire a trigger, I have not yet found a method to handle MTConnect’s multipart/x-mixed-replace
-style streaming.
This is not a deal-breaker — a periodic trigger can be combined with nextSequence
to periodically retrieve any new data — but it looks like Node-RED could more easily handle streaming if the MTConnect spec included a websockets interface.
Regardless of this, it seems that Node-RED could be used to automate actions based on MTConnect, which could make it the basis of a notification flow or a machine monitoring system.
I laughed when I came across this post. I spent a great deal of effort running our MTConnect machines through Node-Red and learning all the quirks of the MTConnect schema. It has been running now for 6+ years and streaming the events, conditions and samples for 3 machines (all Mazak CNC) to an analytics platform; first cloud-based and now on-premise. The knowledge from building this originally in VB.NET as a service on the agent was useful but even more useful as more developers created applications to handle MTConnect. Often I would find they stopped too soon in the node and missed most of the data for that particular stream.
We have a new machine (Okuma) and I had to add that machine to the Node-Red flow. I was staring at very similar screens above all day as this end points for this use-case was different and the Okuma structure is slightly different. Now getting asked about THINC and I respond “Why?” as we are getting what we need already…and I can access that data from anywhere in the world without touching the machines!