Skip to content

Serial Monitor and Serial Plotter

The Serial Monitor and Serial Plotter in the Arduino IDE are your main tools for seeing what your ESP32 is doing. They let you print text and visualize sensor values in real time.


1. Serial basics

In your sketch you use the Serial object:

  • Serial.begin(baudRate) – start the serial connection.
  • Serial.print(...) / Serial.println(...) – send text or numbers.

Example:

void setup() {
  Serial.begin(115200);        // Start Serial at 115200 baud
  Serial.println("Starting..."); 
}

void loop() {
  Serial.println("Hello from ESP32!");
  delay(1000);
}

Open Tools β†’ Serial Monitor and make sure the baud rate in the bottom‑right corner matches the value in Serial.begin(...).


2. Printing sensor values

This example reads an analog sensor (e.g. a potentiometer or LDR) on GPIO 4 and prints the value:

const int SENSOR_PIN = 4;  // ADC pin on many ESP32 DevKit boards

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

void loop() {
  int value = analogRead(SENSOR_PIN);

  Serial.print("Sensor: ");
  Serial.println(value);

  delay(100);
}

You should see numbers scrolling in the Serial Monitor when you turn the knob or change the light level.


3. Using the Serial Plotter

The Serial Plotter (Tools β†’ Serial Plotter) draws incoming values as lines over time.

To plot values:

  • Print only numbers (optionally labeled) separated by spaces or tabs.
  • End each sample with Serial.println().

Example: plot one channel

const int SENSOR_PIN = 4;

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

void loop() {
  int value = analogRead(SENSOR_PIN);

  Serial.println(value);  // one numeric value per line

  delay(20);
}

Example: plot two channels

const int SENSOR_1_PIN = 4;
const int SENSOR_2_PIN = 5;

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

void loop() {
  int v1 = analogRead(SENSOR_1_PIN);
  int v2 = analogRead(SENSOR_2_PIN);

  // Two values separated by a space: plotter draws two lines
  Serial.print(v1);
  Serial.print(" ");
  Serial.println(v2);

  delay(20);
}

4. Debugging tips

  • Nothing appears?

    • Check board and port are correct.
    • Check baud rate in the Serial Monitor.
    • Make sure you called Serial.begin(...) in setup().
  • Gibberish characters?

    • Baud rate mismatch between your sketch and Serial Monitor.
  • Too much data?

    • Add delay(...) in your loop or print less often.

Using the Serial Monitor and Plotter early in your project can save you a lot of time: always print what your code thinks is happening.