The new version 1.6.6 of the Arduino IDE has just been released and one of the most celebrated new features is the inclusion of a window to make graphs with the values received by the serial port.
In this post we will see how to use this simple but useful tool, called “Serial Plotter”, to visualize information sent from Arduino through the serial port.
Arduino Serial Plotter
As we said, the new Arduino IDE incorporates an extension to the traditional serial monitor, which allows real-time display of the values received by the serial port in a graph.
Don’t expect wonders either… it’s a simple tool, very different from what we can obtain by connecting Arduino with an application in Processing, C#, Python or Java (some of which we will discuss soon on the blog).
But precisely this simplicity and ease of use is what makes the serial plotter useful, as it allows us to perform quick tests, or monitor the values of a variable effortlessly.
We find the new “Serial Plotter” in the “Tools” menu, right next to the traditional “Serial Monitor”.
Let’s show its use with a simple example. To do this, we start by connecting Arduino via USB, as we saw in the post Arduino Communication with Serial Port.
We load the following code into Arduino. It simply generates random numbers between 1 and 3 with two decimals, and sends them through the serial port every 100 ms.
void setup() {
Serial.begin(9600);
}
void loop() {
float value;
value = random(100,300)/100.0;
Serial.println(value);
delay(100);
}
The result you will obtain is similar to the image below.
Of course, in a real application the displayed value would be a monitored variable such as, for example, the measurement made by one of the many sensors we have seen on the blog. Similarly, we should adjust the time between shipments to the desired measurement frequency.
We see that, despite its limitations, it is a useful tool due to its simplicity for carrying out quick tests and setups. Hopefully, in future versions, they will improve and add new functionalities to the Serial Plotter.
Download the code
All the code from this post is available for download on Github.