Arduino Nano 33 IoT - Serial Plotter

This guide shows you how to use the Serial Plotter in the Arduino IDE with an Arduino Nano 33 IoT board.

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×Optionally, DC Power Jack
1×Breadboard
1×Jumper Wires
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of Serial Plotter

The Serial Plotter is a tool in the Arduino IDE that can get data from the Arduino Nano 33 IoT using a serial connection and display it on a graph. It can show information from several sensors on one screen.

To get data from the Arduino Nano 33 IoT, connect it to your computer using a USB cable.

Serial Plotter has two parts:

  • A selection box: This is used to choose the serial transfer speed.
  • A graph: This is a screen that displays data visually.

◦ X-axis: Shows time with 500 points. The space between each point matches the time difference between two consecutive Serial.println() function calls.

◦ Y-axis: Shows the data values sent by the Arduino Nano 33 IoT. It automatically adjusts when the values go up or down.

How To Open Serial Plotter

In Arduino IDE, click on Tools and then choose Serial Plotter.

how to open serial plotter

How to plot a Single Line on Graph

To draw one line on the graph, simply send your data ending with the \r\n characters. You can use the Serial.println() function.

Serial.println(variable);

※ NOTE THAT:

Serial.println() automatically adds a carriage return and a new line to the data.

Example Code

This sample Arduino Nano 33 IoT code reads a number from an analog input pin and sends it to the Serial Plotter.

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-serial-plotter */ void setup() { Serial.begin(9600); } void loop() { int variable_1 = analogRead(A0); Serial.println(variable_1); delay(100); }

Detailed Instructions

If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:

  • Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
  • Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
  • Launch the Arduino IDE on your computer.
  • Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
  • Copy the code shown above and paste it into the Arduino IDE.
  • Click the Upload button in the Arduino IDE to compile and send the code to the Arduino Nano 33 IoT board.
  • Open the Serial Plotter.
  • Choose 9600 as the baud rate.
  • Look at the graph in the Serial Plotter.
serial plotter example single line

How to plot multiple lines on Graph

To draw a graph with many numbers, separate each number using a tab ( ) or a space. The last number should end with a new line (carriage return and line feed).

A Simple Explanation:

  • This is the first variable.
Serial.print(variable_first);
  • The variables in the middle
Serial.print("\t"); // Prints a horizontal tab; you could also use Serial.print(" ") to print a space Serial.print(variable_nth);
  • The final variable
Serial.print("\t"); // Print a tab character (alternatively, use Serial.print(" ") for a space) Serial.println(variable_last); // Print the value of variable_last followed by a newline

Example Code

Below is an example code for the Arduino Nano 33 IoT. It reads data from 4 analog input pins and sends it to the Serial Plotter.

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-serial-plotter */ void setup() { Serial.begin(9600); } void loop() { int variable_1 = analogRead(A0); int variable_2 = analogRead(A1); int variable_3 = analogRead(A2); int variable_4 = analogRead(A3); Serial.print(variable_1); Serial.print(" "); // A whitespace character is printed to separate the values. Serial.print(variable_2); Serial.print(" "); // A whitespace character is printed to separate the values. Serial.print(variable_3); Serial.print(" "); // A whitespace character is printed to separate the values. Serial.println(variable_4); // The final value is printed and ended with a carriage return and a newline. delay(100); }

This is what shows up on the Serial Monitor:

serial plotter multiple lines

Example of 3 Sine Waveforms

The sample Arduino Nano 33 IoT code below shows three sine wave values on the Serial Plotter.

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-serial-plotter */ void setup() { Serial.begin(9600); } void loop() { for (int i = 0; i < 360; i += 5) { float sine_1 = 1 * sin(i * M_PI / 180); float sine_2 = 2 * sin((i + 90) * M_PI / 180); float sine_3 = 5 * sin((i + 180) * M_PI / 180); Serial.print(sine_1); Serial.print("\t"); // Outputs a tab (or space) separator between numbers. Serial.print(sine_2); Serial.print("\t"); // Outputs a tab (or space) separator between numbers. Serial.println(sine_3); // Outputs the final number and ends the line with a new line. delay(100); } }

Here is what appears on the Serial Plotter:

serial plotter sine wave

If you want to see this plotter on your smartphone or computer, please check the Arduino Nano 33 IoT - Web Plotter tutotial.

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!