ACS712 + MCP3008 with Raspberry vs Arduino
Posted: Thu Dec 20, 2018 8:24 am
Hi all,
I'am trying to use one ACS712 with MCP3008 and Raspberry, but I'm having problems.
If I use my ACS712 with Arduino everything works well, I get good measurement current .
But now I want to use this with my Raspberry. I use a MPC3008,ACS712 output is analog value. But when I try to read current with my raspberry I don't have same value with my Arduino.
I use same formula, my MCP works, I have tried to read battery voltage and I read the good value.
I use voltage divider (R1 => 1.2k and R2 => 1.8k) in MCP DOUT because Vcc and Vref are 5V.
The zero current value seems to be good I get 512 (1024/2) from MCP3008. But If i plug a charge on ACS712 value doesn't change...
for read MCP channel (On my Arduino I don't use this function, I use AnalogRead function)
For read current (I use the same function on Arduino)
So, I get the same result with or without charge in my ACS712, I am a little lost because the same code works on arduino... Why? MCP is not accurate enough ?
Thanks
I'am trying to use one ACS712 with MCP3008 and Raspberry, but I'm having problems.
If I use my ACS712 with Arduino everything works well, I get good measurement current .
But now I want to use this with my Raspberry. I use a MPC3008,ACS712 output is analog value. But when I try to read current with my raspberry I don't have same value with my Arduino.
I use same formula, my MCP works, I have tried to read battery voltage and I read the good value.
I use voltage divider (R1 => 1.2k and R2 => 1.8k) in MCP DOUT because Vcc and Vref are 5V.
The zero current value seems to be good I get 512 (1024/2) from MCP3008. But If i plug a charge on ACS712 value doesn't change...
for read MCP channel (On my Arduino I don't use this function, I use AnalogRead function)
Code: Select all
def ReadChannel(channel):
adc = spi.xfer2([1,(8+channel)<<4,0])
data = ((adc[1]&3) << 8) + adc[2]
return data
Code: Select all
def getVPP():
result = 0.0
readValue = 0
maxValue = 0
minValue = 1024
for i in range(0,100):
readValue = ReadChannel(current_1_channel) //On Arduino this line is ReadValue = AnalogRead(A0);
if (readValue > maxValue):
maxValue = readValue
if (readValue < minValue):
minValue = readValue
result = ((maxValue - minValue) * 5)/float(1024)
return result;
So, I get the same result with or without charge in my ACS712, I am a little lost because the same code works on arduino... Why? MCP is not accurate enough ?
Thanks
