Introduction
This experiment shows how to measure voltage and current using an Arduino and external sensors.

Components Needed
- Voltage Sensor
- Current Sensor
- Arduino
- Jumper Wires
Circuit Setup
- Connect the voltage sensor’s VCC and GND pins to the 5V and GND on the Arduino.
- Connect the output of the voltage sensor to an analog input pin on the Arduino (e.g., A0).
- Connect the current sensor similarly to measure the current.
The voltage and current sensors read the electrical parameters and send signals to the Arduino for measurement.

Code for Voltage and Current Measurement
Upload the following code to your Arduino to measure voltage and current:
const int voltagePin = A0;
const int currentPin = A1;
float voltage, current;
void setup() {
Serial.begin(9600);
}
void loop() {
voltage = analogRead(voltagePin) * (5.0 / 1023.0);
current = analogRead(currentPin) * (5.0 / 1023.0);
Serial.print("Voltage: ");
Serial.print(voltage);
Serial.print(" V, Current: ");
Serial.println(current);
delay(1000);
}
Explanation
The Arduino measures the voltage and current by reading the sensor outputs and converting the analog values into readable voltage and current values.
Troubleshooting
- Ensure proper calibration of the voltage and current sensors for accurate measurements.
- Check connections for any loose wires or improper connections.