# Power Measurement

I am trying to develop a system that reads the amount of power consumption from my load. Here is how my setup looks like; The led represents a 5W and 12V light bulb(I was unable to get this in my simulator) and the battery i am using is 9 volts Here is my code;

`````` sens = analogRead(A0);
vol = sens * (2.0) * ( 5.0 / 1024.0);
tot_vol = 5 - vol;
current = vol / 10;
power = current * tot_vol;
Serial.print(power);
Serial.print ("\n");
delay(1000);
if(Serial.available() > 0){ // Checks whether data is comming from the serial port
}
if (state == '0') {
digitalWrite(ledPin, LOW); // Turn LED OFF
state = 0;
}
else if (state == '1') {
digitalWrite(ledPin, HIGH);
state = 0;
}
}
``````

I am trying to calculate the voltage drop across my resistor and then get the current and then power from that. This data is sent to an android app via the bluetooth module. However, here is the output i am getting; What am i doing wrong?

• Question: why are you powering a 12V bulb with a 9V battery? – frarugi87 Sep 22 '17 at 12:43

A number of things wrong:

1. You have no ground connection to the Arduino. It can't work out what the voltage you are measuring is relative to. (Read this)
2. You should have the shunt resistor as the absolute last item in your chain of components so it is connected directly to ground (V+ -> LED -> LED's Resistor -> Relay -> Shunt Resistor -> GND
3. Your shunt resistor should be as low as you can get away with - low enough that it doesn't affect the circuit, yet high enough that you can measure a voltage drop. For that you need to first have a good idea about what level of current you will be measuring. simulate this circuit – Schematic created using CircuitLab

• Hi, i have updated the question with 2 images that represent my current situation(after following your instructions). I am getting roughly 0.48 watts per second for a 5w and 12v light bulb. Kindly advice if the power readings i am getting are accurate. – Vic Sep 21 '17 at 3:37
• Your analog input is connected to the wrong side of the relay. – Majenko Sep 21 '17 at 8:01
• Where should the analog input be connected? – Vic Sep 22 '17 at 8:48
• To the high side of the resistor. I will draw a circuit. – Majenko Sep 22 '17 at 8:48

Normally the shunt resistor (in you schema 220 ohm) is way lower than the load it should measure, 12volt/5Watt = 0.42 Amp and R = U/I, 9V/0,42A = 21ohm. So your 220ohm's shunt is inflicting on the measurement value.

So to change the current measurement circuit you have to use a low ohm resistor and since the voltage drop over a shunt/low ohm resistor is small you need a amplifier.

Here is a page about how to calculate a shunt and use it with Arduino: http://www.vwlowen.co.uk/arduino/current/current.htm

If we use a simplified version, 8v over the lamp and 1volt over the shunt.

U = I x R

Rlamp = 21 ohm

Ilamp = 8 volt/21 ohm

Rshunt = U/I = 1 volt/0.42 Amp

• Thank you. Even if i change the resistor to 10 ohms, the output does not really change – Vic Sep 14 '17 at 8:59
• Yes, you need to be below the resistant of the light bulb (0,42 ohm). I will modify my answer with the formula. – MatsK Sep 14 '17 at 9:08