Go Down

Topic: Measure current (Read 203 times) previous topic - next topic

Kalveo

Hi!

I am trying to measure current with my Arduino Uno, and I want some opinions on my solution. Is this the right way to go?

Circuit: https://www.dropbox.com/sh/etny3sgyzmgrn9e/HMYVGX15Rm
(The LED in the image could be switched to whatever I need to measure)

Code: [Select]
const byte Vin0 = A0;
const byte Vin1 = A1;
const float R = 2.0;


void setup(){
  Serial.begin(9600);
}

void loop(){
  float V0 = analogRead(Vin0);
  float V1 = analogRead(Vin1);
  float I = (5.0 * (V0 - V1)) / (R * 1023);
 
  Serial.print("[ Voltage: ");
  Serial.print(5.0 * V0 / 1023);
  Serial.print(" V Current: ");
  Serial.print(I * 1000);
  Serial.println(" mA ]");
 
  delay(500);
}

dancombine

Hi,

yes that is doable.
However you are doing 2 analog reads, one after the other. So your voltage could have changed in the meantime.

I would suggest you put your 2 Ohm resistor at the bottom connected to ground (so swap position with the 200 Ohm R).
This way you measure against Ground, and you only need to do ONE analogread.

-Dan

Go Up