user37426: 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
state = Serial.read(); // Reads the data 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?

user1576: 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

37426: <p>I am trying to develop a system that reads the amount of power consumption from my load. Here is how my setup looks like;
<a href="https://i.stack.imgur.com/Fl2Bj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fl2Bj.png" alt="enter image description here"></a></p>

<p>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;</p>

<pre><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() &gt; 0){ // Checks whether data is comming from the serial port
state = Serial.read(); // Reads the data from the serial port
}
if (state == '0') {
 digitalWrite(ledPin, LOW); // Turn LED OFF
 state = 0;
}
else if (state == '1') {
 digitalWrite(ledPin, HIGH);
 state = 0;
 } 
}
</code></pre>

<p>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;
<a href="https://i.stack.imgur.com/w4oTd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w4oTd.png" alt="enter image description here"></a></p>

<p>What am i doing wrong?</p>
 1576: <p>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.</p>

<p>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.</p>

<p>Here is a page about how to calculate a shunt and use it with Arduino:
<a href="http://www.vwlowen.co.uk/arduino/current/current.htm" rel="nofollow noreferrer">http://www.vwlowen.co.uk/arduino/current/current.htm</a></p>

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

<p>U = I x R</p>

<p>R<sub>lamp</sub> = 21 ohm</p>

<p>I<sub>lamp</sub> = 8 volt/21 ohm</p>

<p>R<sub>shunt</sub> = U/I = 1 volt/0.42 Amp</p>
