Introduction To The Arduino Serial Plotter

Version 1.6.6 of the Arduino IDE is upon us, and with it – among other novelties – is the Serial Plotter, a basic graphing utility for visualizing data, debugging and show-off.  What is it, and how to use it? Here’s a little guide…

The Arduino Serial Plotter in action
The Arduino Serial Plotter in action

To open the Serial Plotter, Choose Tools->Serial Plotter in the main menu (or click Ctrl+Shift+L in Windows). Assuming there’s an Arduino connected, the plotter window will open up. There, at the bottom left, you can select the baud rate – just like you would for the good old Serial Monitor. Other than that, everything is automated – you can’t define, change or manage anything else. This is the Arduino simplicity at its best; if you have more complex requirements, there are plenty of advanced tools and products out there.

Opening the Serial Plotter
Opening the Serial Plotter

Data

The Serial Plotter plots numbers as they arrive on the serial connection. For a number to be considered valid for display, it has to be:

  1. In text form (e.g. the three character sequence “123” for one-hundred and twenty three). Don’t worry about this too much – when you Serial.println(x) and x is a number, it will be sent in text form.
  2. Without any preceding or trailing graphical characters (apparently you can surround the number with ASCII characters #0 – #32, inclusive, but why would you?)
  3. Terminated with the usual end-of-line characters (those that are sent automatically by Serial.println).

The numbers can be negative, floating point, big or small, But they have to be in base 10.

Axes

The graph’s X axis is invisible, and it represents only the order in which valid numbers arrived, from left to right. It does NOT take time into account. You can stretch the Plotter window, but the graph will always show 500 numbers. As more numbers arrive, the graph scrolls and there’s no way to go back.

The Y axis adjusts dynamically to the minimum and maximum of the incoming numbers, and adds a safety margin as well in both directions.

Data points are drawn in blue, and connected with blue lines.

Example

Here’s a little inefficient Arduino sketch to draw a basic sine wave on the Serial Plotter:

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

void loop() {
  for (int j = 0; j < 360; j++) {
   Serial.println(sin(j * (PI / 180)));
  }
}

Disclaimer

Everything I wrote here is based on my own early experiments with the Serial Plotter, without even reading its source code yet. Comments and corrections are welcomed!

Update: Here’s a short video I made about Arduino’s Serial Plotter.

Leave a Reply

Your email address will not be published. Required fields are marked *

four − one =