Page 1 of 1

Battery voltage reading via ADC

Posted: Tue Sep 05, 2017 2:37 am
by mustafacc
I'm seeing an interesting behavior from the ESP32 ADC when I'm trying to measure the ESP32's power supply's voltage (LiPo battery).

I have my source supplying battery connected to a voltage divider (since the board is powered by 3.3v), and that divided voltage is connected to an ADC pin.

I'm reading voltage into the pin and doubling it to get the actual voltage of the battery, however, I'm always seeing a mismatch between the actual battery voltage (as measured by a high accuracy external multimeter) and the voltage read by the ADC as seen in the table below:

Image
Image

The mismatch is decreased as the battery voltage decreases, I double checked the accuracy of the voltage divider resistors and they are in fact equal.

Any clue why this is happening? and how to deal with it?

Re: Battery voltage reading via ADC

Posted: Tue Sep 05, 2017 2:45 am
by WiFive

Re: Battery voltage reading via ADC

Posted: Tue Sep 05, 2017 2:27 pm
by iot_guy
What value resistors are you using in the potential divider? How are you calculating the voltage values from the ADC binary value?

One of the things to consider is that the divider will add series impedance which will act with the ADC input impedance to form another divider. This is why buffers are often used before ADC inputs. The error will depend on the values used in the divider.

Re: Battery voltage reading via ADC

Posted: Mon Oct 23, 2017 4:55 pm
by ayavilevich
iot_guy wrote:What value resistors are you using in the potential divider? How are you calculating the voltage values from the ADC binary value?

One of the things to consider is that the divider will add series impedance which will act with the ADC input impedance to form another divider. This is why buffers are often used before ADC inputs. The error will depend on the values used in the divider.
Hi iot_guy,

I am planning to use a voltage divider made of 20K an 100K resistors to drop the battery voltage so that it is in range of 1.1V ADC reference.
How will impedance of the ADC affect me? Can you explain the considerations? What is the impedance of the ESP32?

Thanks.

Re: Battery voltage reading via ADC

Posted: Tue Oct 24, 2017 11:58 am
by iot_guy
Hi ayavilevich,
I afraid can't find data for the ADC input impedance unfortunately. The original problem posted is probably much more to do with ADC calibration (that WiFive links to) than ADC input impedance.

In your case the ADC input impedance will be in parallel with your 20k resistor. But the ADC input impedance will not be accurate i.e. it will vary from chip to chip and may even vary over the input range. This is not a problem specific to ESP32, many/all micro-controllers have less than ideal input impedance.

Some options are:
  • Use smaller value resistors for the divider - consider only switching the divider in when needed if too much power is wasted by having the divider there all the time. When measuring battery voltage the (temporary) extra load of the divider can be a good thing i.e. avoids false open circuit battery voltage reading.
  • Use a buffer so that the divider feeds the very high input impedance of the buffer and the buffer drives the ESP32 ADC pin and therefore makes the ADC input impedance irrelevant (the buffer will have a very low output impedance unlike your divider).

Re: Battery voltage reading via ADC

Posted: Wed Oct 25, 2017 6:41 am
by ayavilevich
Hi iot_guy,

Thanks for your suggestions. I also wasn't able to find information about the ADC input impedance of the ESP32.

By "switching the divider", do you mean using a transistor of some kind or is there a better way?
By using a buffer, do you mean using a capacitor in series or is there a better way? What capacitor value would you recommend?

Thanks,
Arik.

Re: Battery voltage reading via ADC

Posted: Wed Oct 25, 2017 9:48 pm
by iot_guy
Hi ayavilevich,
By "switching the divider", do you mean using a transistor of some kind or is there a better way?
Yes, or better than a transistor in this case use a MOSFET. A transistor will have a VCE saturation voltage where as the MOSFET will act more like a switch with just a small resistance (RDS on).
By using a buffer, do you mean using a capacitor in series or is there a better way? What capacitor value would you recommend?
No, I mean a buffer like an OP-AMP with unity gain.

Re: Battery voltage reading via ADC

Posted: Thu Oct 26, 2017 7:25 am
by loboris
ayavilevich wrote:...By "switching the divider", do you mean using a transistor of some kind or is there a better way?
Use High-Side switch and put the voltage divider as "Load".
Image