Serial plotter output too fast

I am using the serisl plotter for the first time; however, it draws the graph so fast that it is basically useless.

The IDE is 2.3.2.
The sketch is:

#include <Arduino.h>

const uint16_t DELAY_TIME = 500;

void plot_sin_cos();

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  plot_sin_cos();
}

void plot_sin_cos()
{
  for (uint16_t i = 0; i < 360; i++)
  {
    Serial.print(2);
    Serial.print(" ");
    Serial.print(-2);
    Serial.print(" ");
    Serial.print(cos(DEG_TO_RAD * i));
    Serial.print(" ");
    Serial.print(sin(DEG_TO_RAD * i));
    Serial.println();
    delay(DELAY_TIME);
  }
}

This is what the graph looks like:

Is there no time scaling, or a setting to show more points on the X-axis before scrolling vertically?

It shows what your program sends. Print out the points slowerfaster if you want slowerfaster results.

With DELAY_TIME=5 I get:

Thanks... but doesn't work for me.
I am not getting a single complete curve.
With 5ms I get more data, but the plot is still 5 points on the x-Axis.
How can I see, say 50 or a 100 points on X?

I'm sorry, the Wokwi serial plotter works in time so the results are different.

The IDE serial plotter works in points, and only has a window of a 50 of points. If you want to show a waveform in 50 points, you need to skip further than i++ for each point.

No need to be sorry :slight_smile:
You mentioned 50 points... I have only 5; where can I change this?

Your number of sample points is too high, right now you are using 360 sample points. reduce it and you can reduce the horizontal scaling. for eg instead of i++ , use i+20. Image below shows the result.

1 Like

Thank you. This works when using i+=20 (not i+20) :slight_smile:

What I meant was to increment in steps of 20, not to use exactly "i+20" instead of i++ in the code.

Another way of displaying the original code in a more friendly way is to increase the number of points being plotted.

I change the number of points plotted in version 2.x.x of the IDE to 500 to match version 1.x.x

The resulting plot is as follows:


500 points plotted on serial plotter.

On version 2.x.x of the IDE, the serial plotter is a web application that is installed as part of the Arduino IDE, since it's running as a web application, bundled source code can be modified on a local machine.

The package can be found in the installation folder of the Arduino IDE:

C:\Users\your username\AppData\Local\Programs\Arduino IDE\resources\app\lib\backend\resources\arduino-serial-plotter-webapp\static\js\main.35ae02cb.chunk.js

This file can be edited to change the number of points plotted.
You need to edit the line:

U=Object(o.useState)(50) 

and change it to:

U=Object(o.useState)(500) 

Using Notepad, or Notepad++ just search for 'U=Object(o.useState)', and change the (50) to (500) , or whatever you choose.
You can always change it back if you want to.

Hint: If you decide to do this, make a note of how it's done as you need to repeat the procedure whenever you update the IDE.

3 Likes

Hi @MaxG.

I see the fact that the default number is 50 rather than 5 as you originally thought was already clarified earlier in the thread. For those who would like to have more than 50, I'll mention here that the Arduino IDE developers are tracking the request here:

If you have a GitHub account, you can subscribe to that thread to get notifications of any new developments related to this subject:

Until then, you can use the workaround solution provided by @JohnLincoln in post #9.

2 Likes

Thank you, ptillisch.

My reply in post #9 was based on a post on that github page:
"Alex-Tsyganok commented on Dec 5, 2022".

A post was split to a new topic: Serial plotter tips for scholl class

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