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:
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?
Battery voltage reading via ADC
Re: Battery voltage reading via ADC
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.
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.
-
- Posts: 5
- Joined: Sat Oct 07, 2017 8:50 am
Re: Battery voltage reading via ADC
Hi iot_guy,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.
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
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:
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).
-
- Posts: 5
- Joined: Sat Oct 07, 2017 8:50 am
Re: Battery voltage reading via ADC
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.
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
Hi ayavilevich,
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 "switching the divider", do you mean using a transistor of some kind or is there a better way?
No, I mean a buffer like an OP-AMP with unity gain.By using a buffer, do you mean using a capacitor in series or is there a better way? What capacitor value would you recommend?
Re: Battery voltage reading via ADC
Use High-Side switch and put the voltage divider as "Load".ayavilevich wrote:...By "switching the divider", do you mean using a transistor of some kind or is there a better way?
Who is online
Users browsing this forum: Bing [Bot] and 69 guests