Serial input stops

Hi there, I am using Serial input node with NodeRED on my Laptop to receive data coming at a baud rate of 9600 from a NodeMCU. I am receiving around 100 data per second from the NodeMCU. Since the graph node on NodeRED is not capable of handling data at such high speed, I have used a delay node (To allow only 10 data per second) to allow the graph plot smoothly.

This thing goes smooth for some time. After that, The data coming stops and plotting stops. If i restart the NodeRED, it starts working.

There is no issue in data from the NodeMCU as i have checked this with Python script and there is no issue in data coming from the NodeMCU.

Any solutions please.

After roughly how many seconds does the problem show up? That is, how many data points does the graph show? How many pixels wide is your browser window?
What is the memory and CPU usage of the browser?

@jbudd Hi there, Thanks for your response. The problem arises after 2-3 minutes. I am allowing only data for 5 seconds (10 data per second) for the X axis.

First I would check if your problem is the serial port. If you put too many data points in the memory of node-red it can crash.

Let it run without the graph disconnected and a debug connected and rule out where your problem is

If you inject payload into the chart directly (ie, without sending a full new array), the dashboard will append the values to each array, eventually you will run out of memory and/or the browser won't enjoy it any longer.

If you push a full new array to the chart node, it will flush previous values.

example with a function node sending 1000 random elements every second;

const d = Date.now()
function getRandomArbitrary(min, max) {
    return Math.random() * (max - min) + min;
}

const tmp = [
    { 
        series: ["sensor"], 
        data: [[]],
        labels: [""]
    }
]
for(let z=0;z<1000;z++){
    tmp[0].data[0].push({x:(d+z),y:getRandomArbitrary(10,100)})
}
msg.payload = tmp
return msg;

this can run forever in the dashboard.

So in your case, you could "cache" the latest x values and send it, but you don't even have to cache, just send it.

1 Like

@bakman2 Thanks man. I will try this and let everyone know here.

I just ran it with an inject node set to 0.1 seconds - 1000 elements, looked like a nice oscilloscope :wink:
Appears to behave quite well.

1 Like

@bakman2 Ohh really. Actually i am out. Not with my system. Will check after i reach. This sounds amazing. Can't wait to check myself

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