Voltage and Current Measurement

Introduction

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

Voltage and Current Sensor

Components Needed

Circuit Setup

  1. Connect the voltage sensor’s VCC and GND pins to the 5V and GND on the Arduino.
  2. Connect the output of the voltage sensor to an analog input pin on the Arduino (e.g., A0).
  3. 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.

Voltage and Current Circuit Setup

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