Issue with Real-Time Data Reading from MQTT Node - Unable to Display Graph

Hello,

I'm facing a challenge while trying to display a real-time graph based on data retrieved from an MQTT node in Node-RED. My approach involves reading data from the MQTT node and transforming it into the appropriate format. However, despite my efforts, I'm unable to visualize a functional graph. It seems that I might be missing something in my approach.

Here's a snippet of the code I'm currently using in the function node:

Feed the mqtt node into a debug node and show us what you see in the debug pane.

For real time data you only need to send the y value and maybe a topic to the chart, it will use the current time as x.

eg msg.payload = 42

2

I'm trying to display both time and measurement data from an MQTT node.

So it's not real time then?

Regardless of that, the format you are trying to assemble with series, data and labels arrays is for stored data and I believe that when you send data in that form, the chart node will redraw with a clean sheet. If there's only one data point you don't get any lines on the chart.

Sorry, multiple edits to adjust what my phone thinks I should be saying.

Experiencing timestamp inaccuracies on Node-RED charts due to a time difference between microcontroller data and the clock of the Raspberry Pi running Node-RED.

My issue revolves around the challenge of displaying the data I receive from an MQTT node at specific time intervals on a chart.

Show us an example set of data points, and what you want the chart to look like.

Probably the stored data format is what you need them, but you need to store the data.

Personally I get data from sensors and store it in a database then at intervals run a query to get the most recent couple of hundred records and feed it to the chart.

No doubt it could be done with context storage too

2
I provided the dataset above. The data I intend to display consists of timestamps on the X-axis and measurements on the Y-axis. The chart should be a linear graph.

What units are the timestamps in, and how do you know when to drop samples off the front of the chart?

The time is measured in milliseconds starting from zero, and the data is sent upon pressing a button in the dashboard.

Do you mean each sample is sent to MQTT when the button is pressed? Or is a complete sequence sent when the button is pressed?
If it is a complete sequence then the ideal would be to change the sender so that it sends the whole set as an array instead of a sequence of separate samples.

After pressing the button, an entire series of data is sent until the process is stopped

Do you mean pressing the button starts it sending, then it keeps sending, every 125 msec, until the process is stopped?

Yes, I have two buttons for triggering data transmission and stopping. Is it possible to achieve this without using a database, directly from the data I currently have?

Do you need the chart to build up as the process runs, or would it be ok to wait till it is all received and then draw it?

It would be sufficient if the chart was generated after pressing the stop data transmission button.

I'm not sure what the n in your data is, but if you change the msg (the complete msg, not the msg.payload) to be like

{topic:"myseries", payload:0.135, timestamp:250}

Then it should accept the data and timestamp

I don't quite understand how to do it. Could you elaborate further on how to build the function node?