Arduino - Serial Monitor

About Serial Monitor

Serial Monitor is one of the tools in Arduino IDE. It is used for two purposes:

  • Arduino → PC: Receives data from Arduino and display data on screen. This is usually used for debugging and monitoring
  • PC → Arduino: Sends data (command) from PC to Arduino.

Data is exchanged between Serial Monitor and Arduino via USB cable, which is also used to upload the code to Arduino. Therefore, To use Serial Monitor, we MUST connect Arduino and PC via this cable.

How To Use Serial Monitor

Open Serial Monitor

Click the Serial Monitor icon

Arduino IDE - How to open serial monitor

Items on Serial Monitor

  1. Output console: display data received from Arduino.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
Ln 11, Col 1
Arduino Uno on COM15
2
  1. Autoscroll checkbox: option to select between automatically scroll and not scroll.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
Ln 11, Col 1
Arduino Uno on COM15
2
  1. Show timestamp checkbox: option to show timestamp prior to data displayed on Serial Monitor.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
Ln 11, Col 1
Arduino Uno on COM15
2
  1. Clear output button: clear all text on the output console.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
Ln 11, Col 1
Arduino Uno on COM15
2
  1. Baud rate selection: select communication speed (baud rate) between Arduino and PC. This value MUST be the same as the value used in Arduino code (in Serial.begin() function).
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
Ln 11, Col 1
Arduino Uno on COM15
2

※ NOTE THAT:

When we select baud rate (even the value is not changed), Arduino is reset. Therefore, this is one way to reset Arduino.

  1. Textbox: user can type characters to send to Arduino
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
Ln 11, Col 1
Arduino Uno on COM15
2
  1. Ending selection: select the ending characters appended to data sent to Arduino. Selection includes:
    • No line ending: append nothing
    • Newline: append newline (LF, or '\n') character
    • Carriage return: append carriage return (CR, or '\r') character
    • Both NL and CR: append both newline and carriage return (CRLF, or '\r\n') characters
    Newbiely | Arduino IDE 2.3.8
    ──
    File
    Edit
    Sketch
    Tools
    Help
    Arduino Uno
    Newbiely.ino
    ···
    8 Serial.println("Hello World!");
    Output
    Serial Monitor
    Message (Enter to send message to 'Arduino Uno' on 'COM15')
    New Line
    9600 baud
    Ln 11, Col 1
    Arduino Uno on COM15
    2
    1. Send button: when the button is pressed, Serial Monitor sends data in textbox plus the ending characters to Arduino
    Newbiely | Arduino IDE 2.3.8
    ──
    File
    Edit
    Sketch
    Tools
    Help
    Arduino Uno
    Newbiely.ino
    ···
    8 Serial.println("Hello World!");
    Output
    Serial Monitor
    Message (Enter to send message to 'Arduino Uno' on 'COM15')
    New Line
    9600 baud
    Ln 11, Col 1
    Arduino Uno on COM15
    2

Arduino To PC

To send data from Arduino to PC, we need to use the following Arduino code:

  • Set baud rate and begin Serial port by using Serial.begin() function
Serial.begin(baudrate);
Serial.println("Hello World!");

Example Use

In this example, we will send the “ArduinoGetStarted.com” from Arduino to Serial Monitor every second

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-serial-monitor */ void setup() { Serial.begin(9600); } void loop() { Serial.println("ArduinoGetStarted.com"); delay(1000); }

Quick Steps

  • Copy the above code and open with Arduino IDE
  • Click Upload button on Arduino IDE to upload code to Arduino
  • Open Serial Monitor
  • Select baurate 9600
  • See the output on Serial Monitor
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
ArduinoGetStarted.com ArduinoGetStarted.com ArduinoGetStarted.com ArduinoGetStarted.com
Ln 11, Col 1
Arduino Uno on COM15
2
  • Try changing Serial.println() function to Serial.print() function

PC To Arduino

How to send data from PC to Aduino and read it on Arduino

You will type text on Serial Monitor and then click Send button.

Arduino reads data and process it. To read data, we need to use the following Arduino code:

  • Set baud rate and begin Serial port
Serial.begin(baudrate);
  • Check whether data is available or not
if(Serial.available()) { // TODO }
String data = Serial.readStringUntil("\r\n");

Example Use

In this example, we will send the commands from Serial Monitor to Arduino to turn on/off a built-in LED. The commands include:

  • “ON”: turn on LED
  • “OFF”: turn off LED
How Arduino can receive a complete command? For example, when we send “OFF” command, how Arduino can know the command is “O”, “OF” or “OFF”?

⇒ When sending a command, we will append a newline character ('\n') by selecting “newline” option on Serial Monitor. Arduino will read data until it meets the newline character. In this case, the newline character is called delimiter.

/* * Created by ArduinoGetStarted.com * * This example code is in the public domain * * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-serial-monitor */ void setup() { Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); // set the digital pin as output: } void loop() { if(Serial.available()) // if there is data comming { String command = Serial.readStringUntil('\n'); // read string until meet newline character if(command == "ON") { digitalWrite(LED_BUILTIN, HIGH); // turn on LED Serial.println("LED is turned ON"); // send action to Serial Monitor } else if(command == "OFF") { digitalWrite(LED_BUILTIN, LOW); // turn off LED Serial.println("LED is turned OFF"); // send action to Serial Monitor } } }

Quick Steps

  • Copy the above code and open with Arduino IDE
  • Click Upload button on Arduino IDE to upload code to Arduino
  • Open Serial Monitor
  • Select baurate 9600 and newline option
  • Type “ON” or “OFF” and click Send button
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
Ln 11, Col 1
Arduino Uno on COM15
2
  • See the built-in LED's state on Arduino board. We will see LED's state is ON or OFF, respectively.
  • We also see LED's state on Serial Monitor
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Uno
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Uno' on 'COM15')
New Line
9600 baud
LED is turned ON
Ln 11, Col 1
Arduino Uno on COM15
2
  • Try typing “ON” or “OFF” command some times.

Video Tutorial

We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.

The Best Arduino Starter Kit

※ OUR MESSAGES