Overview
This article shows how you can scale your Node-red visualization to alarge number of sensors. We'll go beyond the tutorials that are readily
available to apply Node-RED to a common Internet of Things (IoT)
scenario. You'll see that what works for one sensor will not work for
many, and a strategy for improving it.
We start by visualizing telemetry for one sensor. It readily shows in
the textual, gauge and chart widgets of the Node-RED dashboard. But,
when we extend it to multiple sensors, the widgets are overrun with
values. We offer one possible solution by changing the problem statement.
The accompanying Youtube video shows this in real-time.
MQTT Lab
We'll be using the MIMIC MQTT Lab accessible on the Internet for free.20 simulated sensors are publishing MQTT telemetry to the public
iot.eclipse.org broker. We have seen this lab in previous articles and
videos.
Single sensor telemetry
We are using Node-RED to visualize our sensor telemetry with thedashboard plug-in, and I'll go through it in detail.
subscribed to a single topic from the public iot.eclipse.org broker.
sensor with telemetry containing acceleration, humidity, pressure and
temperature. Let's focus on temperature.
We can change the temperature at any point in time through the Agent
Variable Store dialog in MIMIC. Let's do this now. Later we'll visualize the
changes.
what happens.
Next comes a json node, which converts the JSON in the payload to a
Javascript object. Let's link the debug node and see what is in the
object. You can see that the temperature value is accessible at
msg.payload.data.temp.value .
counter which counts the messages flowing through it. It feeds into
our dashboard to display the number of messages received. We see it
slowly incrementing.
Let's now link the json node to the rest of the flows to visualize
more of the telemetry.
I'll start by linking the json node to the NOOP node. This is just
a convenience node that will later let me do some easy re-linking.
It just passes the message straight through to some other nodes.
arriving. For now, this is exactly the same as the number of MQTT
messages received.
Telemetry group in the Home dashboard.
the serial number that was received.
received.
payload, which is what the Extract temp node does.
visualization.
value changes from 20000 mCelsius to 10000.
Many sensors
So far so good for one sensor. But, if you want to use this for many,it will not work. Let's try by switching from the single sensor input
node to the many sensor input node labelled Bosch sensors.
tab. The simulated sensors in our MQTT lab are only generating 1
message every 10 seconds on average, so you can see how easy it is
to overwhelm the collector with messages.
and the chart now becomes a jumble of lines for the different sensors.
It's hard to discern anything.
Let's say all the sensors below 80 degree celsius are normal, and
we only want to visualize the sensors that are running too hot.
We can do this with the switch node. It only sends along messages
that have a temperature value higher than 80 degrees.
I use an Inject node named clear stats to inject an empty message to
clear the stats.
We saw how MIMIC MQTT Simulator helps in scaling your NODE-RED
visualization.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.