How to Plot Serial Data in Arduino IDE Quickly and Easily
To plot serial data in the Arduino IDE, use
Serial.begin() to start serial communication and Serial.println() to send numeric data. Then open the Arduino IDE's Serial Plotter from the Tools menu to see the live graph of your data.Syntax
To plot data, you first start serial communication with Serial.begin(baud_rate). Then send data using Serial.println(value) where value is the number you want to plot. The Serial Plotter reads these numbers and draws a graph.
Serial.begin(9600);starts serial communication at 9600 bits per second.Serial.println(value);sends the value followed by a new line.
arduino
void setup() { Serial.begin(9600); // Start serial communication at 9600 baud } void loop() { int sensorValue = analogRead(A0); // Read analog input Serial.println(sensorValue); // Send value to serial delay(100); // Wait 100ms }
Example
This example reads an analog sensor connected to pin A0 and sends its value to the Serial Plotter. The plot updates every 100 milliseconds showing the sensor's changing values.
arduino
void setup() { Serial.begin(9600); // Initialize serial communication } void loop() { int sensorValue = analogRead(A0); // Read sensor Serial.println(sensorValue); // Send data to plotter delay(100); // Delay for readability }
Output
A live graph showing sensor values changing over time in the Serial Plotter window.
Common Pitfalls
Common mistakes include:
- Not calling
Serial.begin()insetup(), so no data is sent. - Sending non-numeric or multiple values without proper formatting, confusing the plotter.
- Using
Serial.print()instead ofSerial.println(), which can cause data to run together and not plot correctly. - Setting a baud rate in the Serial Plotter different from
Serial.begin().
Always match baud rates and send one numeric value per line.
arduino
/* Wrong way: Missing Serial.begin and using Serial.print */ void setup() { // Serial.begin(9600); // Missing! } void loop() { int val = analogRead(A0); Serial.print(val); // No newline, data runs together delay(100); } /* Right way: */ void setup() { Serial.begin(9600); } void loop() { int val = analogRead(A0); Serial.println(val); // Sends value with newline delay(100); }
Quick Reference
- Start serial:
Serial.begin(9600); - Send data:
Serial.println(value); - Open plotter: Tools > Serial Plotter
- Use delay: Add
delay(100);for readable updates - Match baud rate: Plotter baud rate =
Serial.begin()baud rate
Key Takeaways
Always start serial communication with Serial.begin() before sending data.
Send numeric data with Serial.println() to plot each value on a new line.
Open the Arduino IDE Serial Plotter from the Tools menu to see live graphs.
Match the baud rate in Serial.begin() and the Serial Plotter settings.
Use delay() to control how fast data updates for clear plotting.