-->
Page 1 of 2

ADC Read through ACS712

PostPosted: Mon Nov 23, 2015 12:38 am
by Ashutosh choudhary
I am trying to detect the speed of my ceiling fan for which I use ACS712 5A current sensor.
I am able to get it working with arduino but I want to get it working with ESP

The problem is ACS712 is bi-directional so if you supply 5V to it, it will give 2.5V output even if not current is flowing through it. With arduino it's not an issue as it's ADC range is 0-5V. But with eps having 0-1V ADC range it will always give 1023 as output.

Moreover ACS712 5A module gives 185mV/A output (meaning 1A flowing through it, will give 185mV as output, which gets adjusted to the 2.5V of output we were getting earlier). But the thing is ceiling fan consumes 400mA maximum when running at full speed so I get less than 0.09V output variation. which becomes difficult to calculate.

Anyone has an idea on how to get it working with ESP8266-12, or anyone know any unidirectional current senor or any other way of doing it.

Using transformer will make my board bulky and I don't want that.

Thanks in advance

Re: ADC Read through ACS712

PostPosted: Mon Nov 23, 2015 6:02 am
by Barnabybear
Hi, the following advice is a bit rough and ready but should get you up and running, you can refining later if you need to.
I see 3 problems:
1. The output is centred around a 2.5 V offset.
Given that a silicon diode has a forward volt drop of 0.7V. If you put 3 diodes in series between the ACS712 VIOUT that should remove 2.4V of the offset.
VIOUT -->|- -->|- -->|- ADC
Signal diodes would be better than the bigger power type.
There will still be some offset but this can be coded out. Or you can reduce the 5V supply to the ACS slightly to get rid of this (the 0A current of 2.5V is half of the supply voltage to the ACS, if the supply voltage was 4.8V the offset would be 2.4V the same as the diodes).
You now have an output voltage from the ASC of 0V -> 1.1V which reflects the original output of 2.4V -> 3.5V (0 -> 5A) at a resolution of about 25mA per bit. You state the fan draws about 400mA on full load, but because it is AC the peek current will be higher closer to 600mA, which whilst, not brilliant will give you a 24 bits difference between off and full power.

2. The voltage output of the ASC reflects both positive (2.5V -> 3.5V) and negative (2.5V -> 1.5V) current flow as you are measuring AC.
Using the diodes to reduce the offset you have got rid of most of the negative current flow measurement. The problem now is that because the output is at best, the positive half of a sine wave when you measure has a big effect on the accuracy of the result.
The 2 methods that jump to mind are;
Use a capacitor to store the output from the ACS with a resistor to discharge the capacitor (this would be more accurate and may be a good final solution).
The one I would go with for first attempts: Take lots of measurements and discard the ones you don’t want to find the peek current. Something like this:
Loop to take 100 readings.
“current read” = read voltage from ADC pin.
If “current read” > “previous read”
Then “previous read” = “current read”
Back to start of loop.
Depending on the type of speed control the results will vary.

3. The resolution is poor.
The answer is something like this, if you really need to know how fast you fan is running it a 1024 bit resolution.
https://www.sparkfun.com/products/8883

Sorry if this is a bit fragmented – I must have been disturbed 20 times whilst typing it.

Re: ADC Read through ACS712

PostPosted: Mon Nov 23, 2015 12:10 pm
by Venkatesh
I think you found your answer in youtube ;)

Re: ADC Read through ACS712

PostPosted: Tue Nov 24, 2015 8:13 am
by esp03madness
Barnabybear's response is pretty thorough, I don't think I can add to it, but let me just mention some of my own observations.

The output of ACS712 is a sine wave centered at 1/2 VCC, so in your case you'd need it to be swinging between 0-1.1V, centered at 0.55V, or as Barnabybear suggested throw away the negative component and take care of the "gaps" in the signal.

Detecting 400mA at 110/220 will work. However, there is not much room to work with. In my experience, consumption of less than 30W or so is difficult to measure with ACS712.