How to use the Serial Monitor with the Arduino IDE 2.0

The Serial Monitor is an essential tool when creating projects with Arduino. It can be used as a debugging tool, testing out concepts or to communicate directly with the Arduino board.

The Arduino IDE 2.0 has the Serial Monitor tool integrated with the editor, which means that no external window is opened when using the Serial Monitor. This means that you can have multiple tabs open, each with its own Serial Monitor.

You can download the editor from the Arduino Software page.

You can also follow the downloading and installing the Arduino IDE 2.0 tutorial for more detailed guide on how to install the editor.

Requirements

  • Arduino IDE 2.0 installed.
  • Arduino board.
  • Core installed for the board used.

Notable changes

One major change that was introduced with the Arduino IDE 2.0 is the integrated Serial Monitor. The older versions of the editor features an external window that matches the port/board that we select.

The Arduino IDE 2.0 works a bit differently. Instead of opening an external window for the Serial Monitor, it shows up where the console log is located, as an additional tab. To understand how this works, let's take a look at how the old editor works:

img of old editor

Now, let's take a look at the IDE 2.0. Notice how the Serial Monitor is located at the bottom of the editor:

img of new editor

The Serial Monitor settings are also located here, such as adjusting the baud rate and sending messages.

Advantages with new integration

A major advantage with having the Serial Monitor integrated with the editor is the possibility to have multiple monitors open simultaneously. In the old editor, when changing the port/board, it changed across all windows. In addition, we were limited to one Serial Monitor window, an obstacle that the IDE 2.0 removes.

You will find an example with more information on how to use this feature, further down this tutorial under the Using multiple Serial Monitors simultaneously section.

Using the Serial Monitor tool

The Serial Monitor tool is a really great tool for debugging and establishing communication between a computer and an Arduino. To use it is really easy, but there are some things that we need to do first.

  1. First we need to open the Arduino IDE 2.0.

blank ide

  1. Now, we need to create a sketch that includes some configurations needed, so that our board can communicate with our computer. Mainly, we need to set a baud rate, which is done by writing Serial.begin(9600);. Here, the 9600 represents the baud rate, which is the maximum bits per seconds that can be transferred. The sketch that we need to use can be found in the snippet below:
void setup() {
Serial.begin(9600);
}

void loop() {
Serial.println("Hello world!");
delay(1000); 
}
  1. This will print "Hello world!", every one second to the Serial Monitor. Let's select the board we want to use, and upload the sketch to the board.

img select board+upload

  1. When it has finished uploading, click on the Serial Monitor button, located at the top right corner of the IDE. This will launch the Serial Monitor in the bottom of the IDE, replacing the console section.

img of serial monitor button

The text "Hello world!" is now printed every one second. Congratulations, you have now successfully sent a message from your Arduino, to your computer.

Using multiple Serial Monitors simultaneously

A really cool feature with the Arduino IDE 2.0 is that the Serial Monitor is linked to the sketch windows you have open. For example, if we have two sketch windows, named sketch_1 and sketch_2, we can select the port and board for each window, and have two Serial Monitors running at the same time.

This is really useful when working with various communication / connectivity projects, where we want to know what's going on both boards at the same time. If you have two Arduino boards, you can try out this feature using the instructions below.

  1. First, we need to open a new file, through File > New.

img filenew

  1. Now, we need to choose another board. In this example, we are using an Arduino Nano 33 IoT. If you have connected it to your computer and installed the necessary core for it, it will show up in the board list.

img of board list

  1. For the new sketch, let's use the same sketch we uploaded to the other board, but replace the "Hello world!", with something else. In this example, we used "Hello Mars!", as you can see in the code snippet below:
void setup() {
Serial.begin(9600);
}

void loop() {
Serial.println("Hello Mars!");
delay(1000); 
}
  1. Upload the code to the board, and open the Serial Monitor. We should now see "Hello Mars!" being printed every one second. If we put the two sketch windows side by side, we can see how they are printing at the same time.

img of side by side monitors

Congratulations, you can now check what is going on with two boards simultaneously!

Note: Using several sketch windows and Serial Monitor at the same time can be quite heavy on your machine.

More tutorials