danjperron
Posts: 3262
Joined: Thu Dec 27, 2012 4:05 am

So I'd use resistors with these power ratings:
5 ohm 25 to 50 watt
10 ohm 15 to 25 watt
20 ohm 10 to 15 watt
Of course they will never burn. Way way too conservative.

For short term like he will do with a 20% marging.

When I design a board I always add a 50% margin not at 500% to 1000% and I also figure out if I need to put the resistor on heat sink , more copper for smt . But I never put a 500% margin.

A small 100 ohm 1/4 W at 5V will get very hot but will resist unless you put it in a close space.

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

Paul Hutch wrote:
Fri Sep 14, 2018 5:54 pm
Fan174 wrote:
Fri Sep 14, 2018 4:21 pm
I did the experiment with 5 ohms 10 ohms and 20 ohms resistor with 5V at 2 A supply But the three resistor were burnt after few second

So I'd use resistors with these power ratings:
5 ohm 25 to 50 watt
10 ohm 15 to 25 watt
20 ohm 10 to 15 watt
Thhanks Paul

How did you decide power rating
5 ohm 25 to 50 watt
10 ohm 15 to 25 watt
20 ohm 10 to 15 watt

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

danjperron wrote:
Fri Sep 14, 2018 6:09 pm

Of course they will never burn. Way way too conservative.
@danjperron please take look at this measurement

I have 4.5k / 10K

R1 = 4.5 K
R2 = 10k
I measured voltage with multimeter

Vin = 2.56 and

voltage across R1
V1 = 0.82 V
voltage across R2
V2 = 1.73 v

I think Vin = 2.56V and Vout = 1.73 V

I am giving external 5v Dc supply to sensor

Brandon92
Posts: 704
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Fan174 wrote:
Fri Sep 14, 2018 6:09 pm
Brandon92 wrote:
Fri Sep 14, 2018 6:02 pm
Also, what for kind of wire are you using for the current sensor?
I have single core breadboard wire
Okay, do you now the diameter of that wire, I assume 0.2mm2?
Or is this type of wire: jumper wires, breadboard wire

danjperron
Posts: 3262
Joined: Thu Dec 27, 2012 4:05 am

You lost me there!

What is R1 and R2. Are they a new resistor divider to check the 5V or a new divider you put on the ACS-712.

With this new divider

at 0A you will get = 2.5 * (10K/14.5) = 1.72V this is what you get.

at 2A you will get Vout at the ACS712 = (2.5 +66mv*2) = 2.632V then IN1 will be = 1.81V

OK you did increase the resolution. This is what you want to do?

Is it my compensation for the 5V you were trying to do because this is not !

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

danjperron wrote:
Fri Sep 14, 2018 6:30 pm
You lost me there!

OK you did increase the resolution. This is what you want to do?

Is it my compensation for the 5V you were trying to do because this is not !
You suggested me to use 10K/4.7k. I had not 4.7K resistor so i thought it would be better to use 4.5K

What would be new value in this script

ACS712Slope_mVPerA = 33.0
ACS712VoltageOffset = 1.72V

Code: Select all

``````import time

ACS712Slope_mVPerA =  33.0
ACS712VoltageOffset =  1.2038

def ConversionToVolt(values):
return(values * 2.048/32767.0)

def ConversionFromVoltToAmp(values):
return((values -  ACS712VoltageOffset ) * 1000.0 / ACS712Slope_mVPerA)

def ConversionToAmp(values):
return ConversionFromVoltToAmp(ConversionToVolt(values))

GAIN = 2
try:

while True:
values = [0]*4
for i in range(4):
# Read the specified ADC channel using the previously set gain value.
time.sleep(0.5)
print("0:{0:5} {4:1.3f}V {5:2.1f}A\t1:{1:5}\t2:{2:5}\t3:{3:5}".format(*values,ConversionToVolt(values[0]),ConversionToAmp(values[0])))

except KeyboardInterrupt:
pass``````

danjperron
Posts: 3262
Joined: Thu Dec 27, 2012 4:05 am

Ok I post a method to compensate the 5V from the ASC712 by reading it via IN1 to the ADS1115. This way we could correct the output of the ACS712 by calculation.

Has I said the ASC712 output at 0A is VCC/2.0. if VCC fluctuate Vout will! If we know VCC then we are able to correct the voltage offset and the slope using. 5V / VCC read by the ads1115.

This is when I ask to use the 4.5K and 10K. I think I also specified that you could increase the range with 10K and 4k7. Then it is just a question of calculating the new Vofsset and the gain in mv/A

in theory it should be 2.5V * 10K / 14.5K= 1.724V
and the gain in mv/A will be 66mv/A * 10K/14.5 = 45.517mv/A

This you should be able to figure it out at this moment!

I made a small sketch with fritzing for the connection. You will notice that I put two resistors dividers. One for the ACS712 and one for the VCC. The resistor divider use the same resistor 4k5/10K but the divider use the inverse value because VCC has to be reduce way more. This way you could compensate for VCC fluctuation.
CurrentMeter.jpg (89.24 KiB) Viewed 698 times

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

danjperron wrote:
Fri Sep 14, 2018 10:05 pm

I made a small sketch with fritzing for the connection. You will notice that I put two resistors dividers. One for the ACS712 and one for the VCC. The resistor divider use the same resistor 4k5/10K but the divider use the inverse value because VCC has to be reduce way more. This way you could compensate for VCC fluctuation.
I also made sketch for connection I have external supply so I will not use second divider

Please Take look at this connection I have done some connection on real hardware
Pi11.jpg (159.37 KiB) Viewed 670 times
If I get current value between 3.5 A to 4. 2 approx on screen It will prove that we are going on right direction

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

I think power supply is not problem in my case because I am getting constant value

So I think i need to correct slope and offset voltage

Code: Select all

``````import time

ACS712Slope_mVPerA =  45.517
ACS712VoltageOffset =  1.25
def ConversionToVolt(values):
return(values * 2.048/32767.0)

def ConversionFromVoltToAmp(values):
return((values -  ACS712VoltageOffset ) * 1000.0 / ACS712Slope_mVPerA)

def ConversionToAmp(values):
return ConversionFromVoltToAmp(ConversionToVolt(values))

GAIN = 2
try:

while True:
values = [0]*4
for i in range(4):
# Read the specified ADC channel using the previously set gain value.
time.sleep(0.5)
print("0:{0:5} {4:1.3f}V {5:2.1f}A\t1:{1:5}\t2:{2:5}\t3:{3:5}".format(*values,ConversionToVolt(values[0]),ConversionToAmp(values[0])))

except KeyboardInterrupt:
pass
``````

Code: Select all

``````0:32767 2.048V 17.5A	1:   -2	2: 6759	3:   -1
0:32767 2.048V 17.5A	1:   -2	2: 5934	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 4716	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 6250	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 6735	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 7985	3:   -1
0:32767 2.048V 17.5A	1:   -2	2: 6792	3:   -1
0:32767 2.048V 17.5A	1:   -2	2: 7556	3:   -1
0:32767 2.048V 17.5A	1:   -2	2: 6275	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 4434	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 6103	3:   -2
0:32767 2.048V 17.5A	1:   -1	2: 6731	3:   -1
0:32767 2.048V 17.5A	1:   -1	2: 7063	3:   -1
0:32767 2.048V 17.5A	1:   -2	2: 7500	3:   -2
0:32767 2.048V 17.5A	1:   -1	2: 6702	3:   -1
0:32767 2.048V 17.5A	1:   -2	2: 5283	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 4682	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 4510	3:   -1
0:32767 2.048V 17.5A	1:   -1	2: 7924	3:   -1
0:32767 2.048V 17.5A	1:   -2	2: 6630	3:   -2
0:32767 2.048V 17.5A	1:   -1	2: 5271	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 5618	3:   -2
0:32767 2.048V 17.5A	1:   -1	2: 6454	3:   -1
0:32767 2.048V 17.5A	1:   -1	2: 6576	3:   -1
0:32767 2.048V 17.5A	1:   -2	2: 7329	3:   -2
0:32767 2.048V 17.5A	1:   -1	2: 7214	3:   -2
0:32767 2.048V 17.5A	1:   -1	2: 5574	3:   -1
0:32767 2.048V 17.5A	1:   -2	2: 6579	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 4430	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 6189	3:   -2
0:32767 2.048V 17.5A	1:   -2	2: 6559	3:   -1
0:32767 2.048V 17.5A	1:   -1	2: 6539	3:   -2
0:32767 2.048V 17.5A	1:   -1	2: 6377	3:   -2
0:32767 2.048V 17.5A	1:   -1	2: 6082	3:   -1
0:32767 2.048V 17.5A	1:   -1	2: 6250	3:   -2
0:32767 2.048V 17.5A	1:   -1	2: 4576	3:   -2
``````

Brandon92
Posts: 704
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Did you connect the external 5v supply his ground to the ground of your Rpi? Because you didn't draw it in your picture.

And can you response to this. So, what for kind of wire are you using for the 4A load:
Brandon92 wrote:
Fan174 wrote:
Fri Sep 14, 2018 6:09 pm
Brandon92 wrote:
Fri Sep 14, 2018 6:02 pm
Also, what for kind of wire are you using for the current sensor?
I have single core breadboard wire
Okay, do you now the diameter of that wire, I assume 0.2mm2?
Or is this type of wire: jumper wires, breadboard wire

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

Brandon92 wrote:
Sat Sep 15, 2018 11:09 am
Did you connect the external 5v supply his ground to the ground of your Rpi? Because you didn't draw it in your picture.
I forgot to draw in picture but I have connected ground in real hardware
Brandon92 wrote:
Sat Sep 15, 2018 11:09 am
And can you response to this. So, what for kind of wire are you using for the 4A load:
I am using this wire http://www.hobbytronics.co.uk/breadboard-wire
Overall diameter 1.2mm

danjperron
Posts: 3262
Joined: Thu Dec 27, 2012 4:05 am

Having another 5V for the ACS712 is a good idea but it has to be analog. Not another adapter using using switching.
I also made sketch for connection I have external supply so I will not use second divider
You are missing the point! Could you assure me that your external 5V is +/- 0.01V all the times! If not then you are back to square one.

The reason is that you are using a very small portion of your current sensor and the voltage slope against current difference is very low. The offset of the current sensor at 0A is VCC/2. So if VCC varies the output voltage will and using a constant offset ther is pointless.

So the best approach will be. (Looks like I repeat myself all the time).

1 - Read VCC and ACS712 and get their real Voltage after conversion from the resistor ratio. You need to display the real Voltage at VCC and ACS712.
VCC ~ 5V and ACS712 should be ~2.5V
2 - Correct the ACS712 signal against VCC.
new ACS712 Voltage = Current ACS712Voltage * 5V/ VCC voltage read from ADS1115.

This way the signal offset will be always 2.5V or very near. A simple adjustement will work.

This mean that you need to measure the resistor with a multimeter to get the correct ratio. For the resistor divider.

B.T.W. the 1K resistor is not needed in your schema. Thevenin theorem explain that the 10K and 4k5 do the same thing.

You should have all the calculation in your hand now. Try to figure it out. If you can'y I will see if I could create a python script with all the calculation but i'm buzy today.

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

danjperron wrote:
Sat Sep 15, 2018 1:37 pm
Having another 5V for the ACS712 is a good idea but it has to be analog. Not another adapter using using switching.
I have measured output voltage 2.56v at sensor and input voltage 5.12 at sensor
danjperron wrote:
Sat Sep 15, 2018 1:37 pm
This mean that you need to measure the resistor with a multimeter to get the correct ratio. For the resistor divider..
R1 = 4.5 K
R2 = 10 K
V1 = 0.82 V
V2 = 1.73 V

What would be the offset voltage and slope

danjperron wrote:
Sat Sep 15, 2018 1:37 pm
2.5V * 10K / 14.5K= 1.724V
and the gain in mv/A will be 66mv/A * 10K/14.5 = 45.517mv/A .
It means offsetvoltage would be = 1.724V and slope would be 45.517mv/A
danjperron wrote:
Sat Sep 15, 2018 1:37 pm
If you can'y I will see if I could create a python script with all the calculation but i'm buzy today..

danjperron
Posts: 3262
Joined: Thu Dec 27, 2012 4:05 am

This is the new script.

It is all you need.

The Voffset is the real offset provide by ACS712-30 then it is 2.5V

This script return the Voltage before the resistor divider. it back calculate the real Voltage.

https://gist.github.com/danjperron/039e ... c9ffab282a

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

danjperron wrote:
Fri Sep 14, 2018 10:05 pm

I made a small sketch with fritzing for the connection. You will notice that I put two resistors dividers. One for the ACS712 and one for the VCC. The resistor divider use the same resistor 4k5/10K but the divider use the inverse value because VCC has to be reduce way more. This way you could compensate for VCC fluctuation.
Please take look at this connection Is it same connection as you done in your diagram

I have not connected sda scal and adr in picture for clarity but in real hardware I have connected

Pi12.jpg (170.35 KiB) Viewed 561 times

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

I haven't done all connection because if i do all connection it becomes difficult to identify because of too many breadboard wires .

I had doubt on following connection
Is it correct ?
pi13.jpg (111.58 KiB) Viewed 551 times
Blue and black are negative wires
Red is positive wires
R1= 4.6 K
R2 = 9.7K

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

danjperron wrote:
Sat Sep 15, 2018 10:50 pm
This is the new script.

It is all you need.

The Voffset is the real offset provide by ACS712-30 then it is 2.5V

This script return the Voltage before the resistor divider. it back calculate the real Voltage.

https://gist.github.com/danjperron/039e ... c9ffab282a
This script give following error

Code: Select all

``````Traceback (most recent call last):
File "currentMeter.py", line 93, in <module>

Brandon92
Posts: 704
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Fan174 wrote:
Sun Sep 16, 2018 7:47 am
danjperron wrote:
Sat Sep 15, 2018 10:50 pm
This is the new script.

It is all you need.

The Voffset is the real offset provide by ACS712-30 then it is 2.5V

This script return the Voltage before the resistor divider. it back calculate the real Voltage.

https://gist.github.com/danjperron/039e ... c9ffab282a
This script give following error

Code: Select all

``````Traceback (most recent call last):
File "currentMeter.py", line 93, in <module>

This is a good exercise for you.
Look at your old code how the "read_adc" function is used and defined. And implement it in this code.

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

Brandon92 wrote:
Sun Sep 16, 2018 8:00 am

This is a good exercise for you.
Look at your old code how the "read_adc" function is used and defined. And implement it in this code.
I have fixed error

Code: Select all

``````IN0:1.6688759300515763  IN1:2.048
Vout:2.4198700985747856  VCC:6.599111111111111
0:26701.2 2.420V -10.10A	1:32767.0 6.599V
IN0:1.6691009369182408  IN1:2.048
Vout:2.420196358531449  VCC:6.599111111111111
0:26704.8 2.420V -10.10A	1:32767.0 6.599V
IN0:1.6757261391033662  IN1:2.048
Vout:2.429802901699881  VCC:6.599111111111111
0:26810.8 2.430V -9.98A	1:32767.0 6.599V
IN0:1.669213440351573  IN1:2.048
Vout:2.420359488509781  VCC:6.599111111111111
0:26706.6 2.420V -10.09A	1:32767.0 6.599V
IN0:1.6763886593218789  IN1:2.048
Vout:2.4307635560167244  VCC:6.599111111111111
0:26821.4 2.431V -9.97A	1:32767.0 6.599V
IN0:1.6656883327738274  IN1:2.048
Vout:2.4152480825220497  VCC:6.599111111111111
0:26650.2 2.415V -10.15A	1:32767.0 6.599V
IN0:1.6581256019775996  IN1:2.048
Vout:2.4042821228675195  VCC:6.599111111111111
0:26529.2 2.404V -10.28A	1:32767.0 6.599V
IN0:1.6726385448774683  IN1:2.048
Vout:2.425325890072329  VCC:6.599111111111111
0:26761.4 2.425V -10.04A	1:32767.0 6.599V
IN0:1.6781137119663077  IN1:2.048
Vout:2.433264882351146  VCC:6.599111111111111
0:26849.0 2.433V -9.94A	1:32767.0 6.599V
IN0:1.678188714255196  IN1:2.048
Vout:2.433373635670034  VCC:6.599111111111111
0:26850.2 2.433V -9.94A	1:32767.0 6.599V
IN0:1.6786887295144506  IN1:2.048
Vout:2.4340986577959534  VCC:6.599111111111111
0:26858.2 2.434V -9.94A	1:32767.0 6.599V
IN0:1.6786012268440809  IN1:2.048
Vout:2.4339717789239175  VCC:6.599111111111111
0:26856.8 2.434V -9.94A	1:32767.0 6.599V
IN0:1.6784887234107486  IN1:2.048
Vout:2.4338086489455852  VCC:6.599111111111111
0:26855.0 2.434V -9.94A	1:32767.0 6.599V
IN0:1.6771011810663166  IN1:2.048
Vout:2.431796712546159  VCC:6.599111111111111
0:26832.8 2.432V -9.96A	1:32767.0 6.599V
IN0:1.6790887417218543  IN1:2.048
Vout:2.4346786754966887  VCC:6.599111111111111
0:26864.6 2.435V -9.93A	1:32767.0 6.599V
IN0:1.6726885464033936  IN1:2.048
Vout:2.4253983922849205  VCC:6.599111111111111
0:26762.2 2.425V -10.04A	1:32767.0 6.599V
IN0:1.677551194799646  IN1:2.048
Vout:2.432449232459487  VCC:6.599111111111111
0:26840.0 2.432V -9.95A	1:32767.0 6.599V
IN0:1.6781012115848262  IN1:2.048
Vout:2.433246756797998  VCC:6.599111111111111
0:26848.8 2.433V -9.95A	1:32767.0 6.599V
IN0:1.6769011749626148  IN1:2.048
Vout:2.4315067036957916  VCC:6.599111111111111
0:26829.6 2.432V -9.97A	1:32767.0 6.599V
IN0:1.6792137455366678  IN1:2.048
Vout:2.4348599310281682  VCC:6.599111111111111
0:26866.6 2.435V -9.93A	1:32767.0 6.599V
IN0:1.67877623218482  IN1:2.048
Vout:2.4342255366679892  VCC:6.599111111111111
0:26859.6 2.434V -9.93A	1:32767.0 6.599V
IN0:1.6784512222663046  IN1:2.048
Vout:2.4337542722861416  VCC:6.599111111111111
0:26854.4 2.434V -9.94A	1:32767.0 6.599V
IN0:1.6778387035737174  IN1:2.048
Vout:2.4328661201818904  VCC:6.599111111111111
0:26844.6 2.433V -9.95A	1:32767.0 6.599V
IN0:1.6693634449293497  IN1:2.048
Vout:2.420576995147557  VCC:6.599111111111111
0:26709.0 2.421V -10.09A	1:32767.0 6.599V
IN0:1.6786137272255623  IN1:2.048
Vout:2.433989904477065  VCC:6.599111111111111
0:26857.0 2.434V -9.94A	1:32767.0 6.599V
IN0:1.6788012329477828  IN1:2.048
Vout:2.434261787774285  VCC:6.599111111111111
0:26860.0 2.434V -9.93A	1:32767.0 6.599V
IN0:1.6790512405774103  IN1:2.048
Vout:2.434624298837245  VCC:6.599111111111111
0:26864.0 2.435V -9.93A	1:32767.0 6.599V
IN0:1.6784762230292674  IN1:2.048
Vout:2.4337905233924375  VCC:6.599111111111111
0:26854.8 2.434V -9.94A	1:32767.0 6.599V
IN0:1.6777011993774225  IN1:2.048
Vout:2.4326667390972627  VCC:6.599111111111111
0:26842.4 2.433V -9.95A	1:32767.0 6.599V
IN0:1.6785887264625996  IN1:2.048
Vout:2.4339536533707693  VCC:6.599111111111111
0:26856.6 2.434V -9.94A	1:32767.0 6.599V
IN0:1.6792137455366678  IN1:2.048
Vout:2.4348599310281682  VCC:6.599111111111111
0:26866.6 2.435V -9.93A	1:32767.0 6.599V
IN0:1.6690759361552783  IN1:2.048
Vout:2.4201601074251538  VCC:6.599111111111111
0:26704.4 2.420V -10.10A	1:32767.0 6.599V
IN0:1.6723385357219154  IN1:2.048
Vout:2.4248908767967774  VCC:6.599111111111111
0:26756.6 2.425V -10.04A	1:32767.0 6.599V
IN0:1.6783512192144534  IN1:2.048
Vout:2.4336092678609575  VCC:6.599111111111111
0:26852.8 2.434V -9.94A	1:32767.0 6.599V
IN0:1.6729885555589465  IN1:2.048
Vout:2.4258334055604727  VCC:6.599111111111111
0:26767.0 2.426V -10.03A	1:32767.0 6.599V
IN0:1.6775386944181647  IN1:2.048
Vout:2.4324311069063387  VCC:6.599111111111111
0:26839.8 2.432V -9.95A	1:32767.0 6.599V
IN0:1.678363719595935  IN1:2.048
Vout:2.433627393414106  VCC:6.599111111111111
0:26853.0 2.434V -9.94A	1:32767.0 6.599V
IN0:1.6763511581774344  IN1:2.048
Vout:2.43070917935728  VCC:6.599111111111111
0:26820.8 2.431V -9.97A	1:32767.0 6.599V
IN0:1.671638514358959  IN1:2.048
Vout:2.4238758458204908  VCC:6.599111111111111
0:26745.4 2.424V -10.05A	1:32767.0 6.599V``````

Brandon92
Posts: 704
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Good that you have found the mistake. And are the values that you are getting what you would expect?

danjperron
Posts: 3262
Joined: Thu Dec 27, 2012 4:05 am

I don't have and ADS1115 so I emulating it.

The line 111, the other print line, is a debug line. Just take it out when thing works.

Did you set your resistors values into the code?
Good that you have found the mistake. And are the values that you are getting what you would expect?
I'm kind of agree with brandon92. What is wrong with the IN0 and IN1?

A small Hint.
Did you read the description in my script? did yo manually check what should be the voltage. Vo = Vi * R1/(R1+R2).
Something odd with your resistor divider for VCC. It should be obvious to you.

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

danjperron wrote:
Sun Sep 16, 2018 12:37 pm
I don't have and ADS1115 so I emulating it.

Did you set your resistors values into the code?
A small Hint.
Did you read the description in my script? did yo manually check what should be the voltage. Vo = Vi * R1/(R1+R2).
Something odd with your resistor divider for VCC. It should be obvious to you.
I have completely lost here before I just had to know offset voltage and slow but now thing are going in very complicated way

Did you check the diagram Is there something wrong in my connection ?

I measured VCC is 4.95 volt

R1= 4.6 K
R2 = 9.7K

What's the problem with external supply. Now i am frustrated After many attempts, I am not getting at least positive sign.

In experiment I found that current always goes in minus but I should be in positive
Last edited by Fan174 on Sun Sep 16, 2018 2:10 pm, edited 2 times in total.

Brandon92
Posts: 704
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Maybe a stupid question, but did you connect the connections to your acs the right way around. If this is not the case, you measure a negative current.

danjperron
Posts: 3262
Joined: Thu Dec 27, 2012 4:05 am

You know this a simple stage. Two resistors divider to get the correct Voltage to the A/D converter. This is not hard.

B.T.W. On the script those resistors are R3 and R4.

The thing we want is to read 5V under the A/D converter reference. Also we want to use something near the full span to increase accuracy.
I decide to use the same value that you used with the resistor divider for the ACS712. But the trick is that you have to invert the value.

if we use the same resistor divider than the ACS712

V at IN1 will be around = 5V * 10K / (4k7 + 10K) = 3.4V Voltage higher then the Vref **** this is not wiorking

But if we swap R3 and R4.

V at IN1 will be around = 5V * 4k7 / (4k7 + 10K) = 1.6V Ok perfect we have good value.

**** Do you see your error on your protoboard and why IN1 is in saturation.

The big problem is the choice of ACS712-30A . Using 30A range to get 2A maximum create huge error on the readout . A small change in VCC will trow the result out. This is why you need to read the 5V on the ACS712 to compensate for it.

try to read all the post again and figure out what it is. The current script with the values of the resistor enter should work.
You will have to play a little bit with the slope and offset of the ACS712 but basically this should work!

Now you need to figure it out! This is up to you.

Fan174
Posts: 171
Joined: Tue Mar 20, 2018 6:10 am

Brandon92 wrote:
Sun Sep 16, 2018 2:08 pm
Maybe a stupid question, but did you connect the connections to your acs the right way around. If this is not the case, you measure a negative current.
I have checked both case before but I don't know what's the wrong happening