How do I get the time from the last point in a Node-red dashboard chart

I have a chart being populated from a datalogger. Sometimes the connection goes bad, so I would like to publish the time of the last plotted point so I can monitor it and potentially act if I have not received data for a while.
Thanks in advance.

Add a debug node to the chart output, the data is all there.

Thanks, yes I can see all there, being new to node-red, some advice on how to pull out what I need.
Is this something I can use a change node to access the data, or are we looking at a function node as the only way to get what I need??

There are probably better ways of doing that. Can you explain in a bit more detail what problem you are trying to catch? What connection is it that goes bad? Where do you want to publish the time to and where do you want to interpret that time?

Thanks, Sure can do that...
The logger I have connects through Wifi (mqtt) and is pushing the connection envelope a bit due to distance.
Mostly it works fine, but I would like to know if it's having a bad day. My thought was if I could capture the time assigned to the last captured point and then publish it to the dashboard I could easily see if I am losing data, eventually I would like to set up a notification, so I would be informed when this happens. Right now, the chart is setup to gather 2 days of data which comes at 30 sec intervals (so there is a lot of points)

If the logger provides MQTT Last Will and Testament then you should be able to use that to detect if it loses connection. See the link below if you don't know about LWT, basically it allows the broker to tell you if the client disconnects.

Otherwise, if you connect a Trigger node to the incoming messages node (as well as going to the chart), and configure the trigger like this

image

Then all the time data keeps coming in it does not send anything. If no data arrives for 10 seconds (or whatever you have configured) then it sends a message, which you can use to do whatever you like.

To learn more about MQTT then see this tutorial MQTT Essentials - All Core Concepts explained

2 Likes

Thank you, much easier than my solution, and so many more possibilities.
I used a Change node to reset the warning message once the data stream continued.
This can now be extended to make a chart showing when data dropouts occurred.
Excellent !

Which solution did you use? LWT or Trigger node?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.