Introduction
In Arduino projects, it is often useful to visualize sensor data instead of just reading numbers in the Serial Monitor. By plotting sensor values as a graph, we can easily understand how the sensor output changes over time.
In this project, we read an analog sensor connected to an Arduino and send the values to the computer using Serial communication. The data is then displayed as a live graph using the Serial Plotter feature available in the Arduino IDE.
🎯 Aim of the Project
To:
-
Read an analog sensor value using Arduino
-
Send the sensor value to the computer using Serial communication
-
Display the value as a real-time graph using Arduino IDE Serial Plotter
🧰 Components Required
-
Arduino Uno
-
Potentiometer (or any analog sensor like LDR, LM35, etc.)
-
Breadboard
-
Jumper wires
-
USB cable
-
Computer with Arduino IDE installed
🔌 Circuit Diagram & Description
Potentiometer Connection:
| Potentiometer Pin | Arduino Pin |
|---|---|
| One end pin | 5V |
| Middle pin | A0 |
| Other end pin | GND |
(If using an LDR, make a voltage divider using LDR and a 10k resistor, and connect the output to A0.)
🧠 Arduino Program
📝 Program Explanation
🔹 Serial.begin(9600);
Starts communication between Arduino and the computer at 9600 baud rate.
🔹 analogRead(A0);
Reads the voltage at analog pin A0 and converts it into a digital value between 0 and 1023.
-
0 → 0V
-
1023 → 5V
🔹 Serial.println(sensorValue);
Sends the sensor value to the Serial Monitor in numeric form, one value per line.
🔹 delay(2);
Provides a small delay to allow the ADC to stabilize and to control the speed of graph plotting.
🧪 Procedure
-
Connect the circuit as per the connection table.
-
Open Arduino IDE.
-
Select:
-
Board: Arduino Uno
-
Port: Correct COM port
-
-
Copy and upload the program to Arduino.
-
Open:
Tools → Serial Plotter -
Set baud rate to 9600.
-
Rotate the potentiometer (or vary sensor input).
📊 Output
-
A live graph is displayed on the Serial Plotter window.
-
As the potentiometer is rotated, the graph moves up and down.
-
Values range from 0 to 1023.
-
The graph updates in real time.
⚙️ Working Principle
-
The sensor produces an analog voltage based on physical changes (rotation, light, temperature, etc.).
-
Arduino converts this voltage into a digital value using its internal ADC.
-
The digital value is transmitted to the computer via Serial communication.
-
Arduino IDE plots this value as a real-time graph using Serial Plotter.
📌 Applications
-
Sensor testing and calibration
-
Data visualization
-
IoT monitoring
-
Temperature analysis
-
Light intensity monitoring
-
Educational demonstrations
⚠️ Tips and Notes
-
Do not print any text with the value when using Serial Plotter.
-
Use only numbers in
Serial.println(). -
Keep baud rate same in code and Serial Plotter.
-
You can replace the potentiometer with:
-
LDR
-
LM35 temperature sensor
-
Gas sensor
-
Soil moisture sensor
-
Force sensor
-
🔁 Variations
-
Plot temperature using LM35
-
Plot light intensity using LDR
-
Plot gas concentration using MQ sensor
-
Plot soil moisture levels
-
Store graph data in Excel using serial logging
🧾 Conclusion
This project shows how analog sensor values can be visualized as a real-time graph using Arduino IDE. It helps beginners understand analog input, serial communication, and data plotting clearly and practically.