sensor-experiments

Introduction

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

Components Needed

No Ads Available.

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.

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

Contact Us

If you have any questions or inquiries, feel free to reach out to us at Microautomation.no@icloud.com .

Follow our Socials for the newest updates!