Arduino Serial Monitor Tutorial: Basics and Alternatives to try - Latest Open Tech From Seeed (2024)

Own an Arduino board an figuring out how to get started with the Arduino Serial Monitor? If so, you’re in the right place! In today’s serial monitor tutorial, I’ll be guiding you on how you can easily get started!

Introduction to the Arduino Serial Monitor

Arduino Serial Monitor Tutorial: Basics and Alternatives to try - Latest Open Tech From Seeed (1)

Before we begin with the tutorial, here’s a quick introduction to the Arduino Serial Monitor for those that are unsure!

We all know about the Arduino IDE; the development environment of Arduino, with a feature that helps users debug sketches and control your device from your computer’s keyboard. But, for this feature to work, it requires The Serial Monitor, a separate pop-up window that receives and sends serial data for communication.

In short, the purpose of the Arduino serial monitor is to help users like yourself to debug Arduino software sketches or viewing data sent by a working sketch.

Step-by-step tutorial of the Arduino Serial Monitor

Step 1: Preparing what is required

  • Arduino Uno
  • USB 2.0 Cable Type A/B

*Other Arduino boards work as well

Connect your Arduino board with the USB cable for activation of Serial Monitor

Step 2: Copy and Paste Sketch into the Serial Monitor

Since your Arduino and sketch resets whenever you start the Arduino Serial Monitor, you’ll need an example Serial Communication Sketch to copy and paste

/* YourDuinoStarter_SerialMonitor_SEND_RCVE - WHAT IT DOES: - Receives characters from Serial Monitor - Displays received character as Decimal, Hexadecimal and Character - Controls pin 13 LED from Keyboard - SEE the comments after "//" on each line below - CONNECTIONS: - None: Pin 13 built-in LED - - V1.01 11/29/2019 FIXED - THANKS! Peter Hellen Questions: [emailprotected] *//*-----( Import needed libraries )-----*//*-----( Declare Constants and Pin Numbers )-----*/#define led 13 // built-in LED/*-----( Declare objects )-----*//*-----( Declare Variables )-----*/int ByteReceived;void setup() /****** SETUP: RUNS ONCE ******/{ pinMode(led, OUTPUT); Serial.begin(9600); Serial.println("--- Start Serial Monitor SEND_RCVE ---"); Serial.println(" Type in Box above, <ENTER>. "); Serial.println("(Decimal)(Hex)(Character)"); Serial.println();}//--(end setup )---void loop() /****** LOOP: RUNS CONSTANTLY ******/{ if (Serial.available() > 0) { ByteReceived = Serial.read(); Serial.print(ByteReceived); Serial.print(" "); Serial.print(ByteReceived, HEX); Serial.print(" "); Serial.print(char(ByteReceived)); if (ByteReceived == '1') // Single Quote! This is a character. { digitalWrite(led, HIGH); Serial.print(" LED ON "); } if (ByteReceived == '0') { digitalWrite(led, LOW); Serial.print(" LED OFF"); } Serial.println(); // End the line }// END Serial Available}//--(end main loop )---/*-----( Declare User-written Functions )-----*///*********( THE END )***********

Step 3: Understanding the Serial Monitor Interface

When you enter the above code, the serial monitor will appear in a new window. It may look daunting when first seen, but here’s a classification of what the boxes are with its relative usages

Arduino Serial Monitor Tutorial: Basics and Alternatives to try - Latest Open Tech From Seeed (2)
What you see on the Serial MonitorWhat it is and What it’s for
Small upper box For typing characters, (hit <enter> or click “send”)
Larger area (can be enlarged by dragging the corner)Displaying characters sent from Arduino
Line Ending PulldownSets “line ending” that will be sent to Arduino when you <enter> or click send
Baude Rate PulldownSets Baud Rate for communications
If baud rate doesn’t match the value set in your sketch setup, characters will be unreadable

*Do check that the sketch used is the same as Baud Rate selected

Step 4: Debugging with Serial Monitor

When you’re testing a new sketch, you’ll need to know what’s happening in the process of trying. You can do so by using the Serial Monitor and adding codes to your sketch for sending of characters.

Setup phase:

During setup, you’ll need to begin serial communications and set baud rate. The code looks like this:

Serial.begin(9600); // Other baud rates can be used...

Loop:

You can print helpful info to the Serial Monitor with the following examples:

Serial.println("Top of loop");Serial.println("Reading Temperature Sensor");Serial.print("LoopCounter value = ");Serial.println(LoopCounter);

You can refer to the Reference section of your Arduino IDE for details on how you can display different data. Top menu being: Help>reference/Serial_Print.html

Arduino Serial Monitor withWiFiShield

Arduino Serial Monitor Tutorial: Basics and Alternatives to try - Latest Open Tech From Seeed (3)

Another way you could get started with the Arduino Serial Monitor is with the Wifi Shield, where there are a plethora of applications made possible with the Serial Monitor.

The following tutorial is on how you can send commands to WiFi Shield and receive responses via the Arduino Serial Monitor!

  • For the full list of applications possible with Arduino Serial Monitor, you can head here!

Step 1: Prepare the following hardware

  • Arduino Uno /Seeeduino
  • WiFi Shield

*The shield we’re using here is based on the RN171 WiFi module

Step 2: Wifi Shield Jumpers Configuration

Position the jumpers in the WiFi shield such that digital pin 2 (D2) is selected for WIFI_TX, and digital pin 3 (D3) is selected for WIFI_RX as shown in the photo below. These are the pins we will use to send and receive information from the RN-171.

Arduino Serial Monitor Tutorial: Basics and Alternatives to try - Latest Open Tech From Seeed (4)

Step 3: Software/Code

In the sketch below, we have created a UART object, allowing us to send and receive data from the RN-171/WiFi Shield. We then use this object in conjunction with the WiFly library to send data to the shield. The Arduino’s Serial object is used to print the data we receive from the shield, and to receive the commands we want to send to the shield via the WiFly/UART object.

Upload the following code to your Arduino board:

#include <Arduino.h>#include <SoftwareSerial.h>#include "WiFly.h"// set up a new serial port.SoftwareSerial uart(2, 3); // create a serial connection to the WiFi shield TX and RX pins.WiFly wifly(&uart); // create a WiFly library object using the serial connection to the WiFi shield we created above.void setup(){ uart.begin(9600); // start the serial connection to the shield Serial.begin(9600); // start the Arduino serial monitor window connection delay(3000); // wait 3 second to allow the serial/uart object to start}void loop(){ while (wifly.available()) // if there is data available from the shield { Serial.write(wifly.read()); // display the data in the Serial monitor window. } while (Serial.available()) // if we typed a command { wifly.write(Serial.read()); // send the command to the WiFi shield. }}

Step 4: Entering Command Mode

The WiFly RN-171 module in the WiFi shield can operate in two modes: data, and command.

  • In data mode: The shield is able to receive and initiate connections
  • In command mode: We’re able to configure the module using commands listed in the datasheet

We’ll enter command mode with the following steps:

  1. Open the Arduino Serial Monitor
  2. Set the serial monitor to “No line ending”, baud rate to 9600.
  3. Type “$$$” into the Arduino Serial Monitor and press enter.
  4. The module will respond with the letters “CMD”, indicating that it has entered command mode.

Let’s go ahead and test some commands with the following:

  1. In the Arduino Serial monitor window, select “Carriage return” and a baud rate of 9600.
  2. Now type each of the commands in the table below into the Arduino Serial Monitor and press enter.
  3. The module will output a response, as described in the table, for each command.
CommandsDescription
scanThis command performs an active probe scan of access points on all 13 channels. When you use this command, the module returns the MAC address, signal strength, SSID name, and security mode of the access points it finds.
get ipThis command displays the IP address and port number settings

For the complete list of configuration commands, check the RN-171 Reference Guide starting on page 11

Using Arduino Serial Monitor on Arduino Web Editor

Arduino Serial Monitor Tutorial: Basics and Alternatives to try - Latest Open Tech From Seeed (5)

Instead of the conventional Arduino Serial Monitor, you could access the web version on Arduino Create Editor, an online platform that allows for not only the same capabilities but isn’t restricted via distance since it can be accessed by the Internet!

You can find the full tutorial at Arduino Project Hub!

Arduino Serial Monitor Alternatives

The Arduino Serial Monitor is only able for basic serial communication but lacks capabilities that other serial monitors offer:

Serial Port Monitor by Eltima (SPM)

Arduino Serial Monitor Tutorial: Basics and Alternatives to try - Latest Open Tech From Seeed (6)

This Serial Port Monitor is a great way to compare and analyze information sent from an Arduino. With this app, you’re able to:

Active monitor COM ports

This app allows for the monitoring of active serial ports once they are detected by the software. This allows for an immediate fix of bugs if one were to appear

Simultaneously monitor multiple ports

With SPM, you’re able to track activities of several COM ports at a time too, with data collection being based on first in, first out method

Filter data and access to visualization modes

Data can be filtered and simplified, allowing you to select what’s relevant. What’s more, is that the data can be displayed in different views; line, table, dump, and terminal.

PuTTY from Simon Tatham:SerialMonitorforWindows

Arduino Serial Monitor Tutorial: Basics and Alternatives to try - Latest Open Tech From Seeed (7)

Another Arduino Serial Monitor alternative is PuTTY, a free SSH and Telnet Client.

With PuTTY, not only is it a good serial terminal option, it can handle telnet, ssh, and a host of other things as well!

If you’re using Windows, it’s a solid alternative to try!

Note: Usage of PuTTY is strictly prohibited in countries where encryption is outlawed. Do ensure you reside in a country that allows its usage. You may find useful information on usability here.

Screen: Serial Monitor for Mac, Linux

Arduino Serial Monitor Tutorial: Basics and Alternatives to try - Latest Open Tech From Seeed (8)

Screen is a command-line based fullscreen VT100 emulator. It makes a create terminal client, with the ability to “detach” from the current terminal to run in the background. Drop to a terminal and run screen!

What’s better; Screen is already on Mac and Linux, without having to download!

Resources and Going Further

Arduino Serial Monitor not working?

Try out the serial monitor with LED:

WiFi Shield Resources

Summary

That’s all for the Arduino Serial Monitor tutorial. If you would like to not only enable your Arduino with WiFi capabilities but try out a wide range of Arduino Serial Monitor capabilities, pick up the WiFi Shield V2.0!

About Author

Shawn

See author's posts

    Tags: arduino guide, arduino ide, arduino tutorial, Arduino WiFi Shield

    Arduino Serial Monitor Tutorial: Basics and Alternatives to try - Latest Open Tech From Seeed (2024)

    References

    Top Articles
    Latest Posts
    Article information

    Author: Melvina Ondricka

    Last Updated:

    Views: 5481

    Rating: 4.8 / 5 (48 voted)

    Reviews: 95% of readers found this page helpful

    Author information

    Name: Melvina Ondricka

    Birthday: 2000-12-23

    Address: Suite 382 139 Shaniqua Locks, Paulaborough, UT 90498

    Phone: +636383657021

    Job: Dynamic Government Specialist

    Hobby: Kite flying, Watching movies, Knitting, Model building, Reading, Wood carving, Paintball

    Introduction: My name is Melvina Ondricka, I am a helpful, fancy, friendly, innocent, outstanding, courageous, thoughtful person who loves writing and wants to share my knowledge and understanding with you.