Battery voltage reading via ADC

mustafacc
Posts: 12
Joined: Fri Sep 01, 2017 12:39 am

Battery voltage reading via ADC

Postby mustafacc » Tue Sep 05, 2017 2:37 am

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?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Battery voltage reading via ADC

Postby WiFive » Tue Sep 05, 2017 2:45 am


iot_guy
Posts: 8
Joined: Thu Aug 31, 2017 8:16 pm

Re: Battery voltage reading via ADC

Postby iot_guy » Tue Sep 05, 2017 2:27 pm

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.

ayavilevich
Posts: 5
Joined: Sat Oct 07, 2017 8:50 am

Re: Battery voltage reading via ADC

Postby ayavilevich » Mon Oct 23, 2017 4:55 pm

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.

iot_guy
Posts: 8
Joined: Thu Aug 31, 2017 8:16 pm

Re: Battery voltage reading via ADC

Postby iot_guy » Tue Oct 24, 2017 11:58 am

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).

ayavilevich
Posts: 5
Joined: Sat Oct 07, 2017 8:50 am

Re: Battery voltage reading via ADC

Postby ayavilevich » Wed Oct 25, 2017 6:41 am

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.

iot_guy
Posts: 8
Joined: Thu Aug 31, 2017 8:16 pm

Re: Battery voltage reading via ADC

Postby iot_guy » Wed Oct 25, 2017 9:48 pm

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.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: Battery voltage reading via ADC

Postby loboris » Thu Oct 26, 2017 7:25 am

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

Who is online

Users browsing this forum: No registered users and 62 guests