Pages: [1]   Go Down
Author Topic: Measure current  (Read 198 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 102
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: