# ESP32. - selecting resistors for voltage divider

I'm using an ESP32 with a 12V battery and solar panel. I've created a voltage divider for 0-15v (3.3v input to MCU at 15v at battery side). For that I used a 100kOhm , and 300kOhm to get a 0.3 ratio.

For measuring purposes, result measured is close enough (0.1v error), but Battery-wise, selecting those resistors were a good choice ?

EDIT_1

1. MCU is powered using that 12v battery, using a buck converter.

2. 12v battery is used, since it has a much bigger capacity (7Ah).

3. Charge voltages can get up to 13.5-14.0v, I took 15v as a upper limit.

4. The reason for asking was NOT about what ratio is better (0.3 or 0.25) in voltage divider, but what is right for consuming less power due to that R selection, since it seems battery drainage is faster than I expected.

• Is the 3.3 volts from the voltage divider intended to provide power to the ESP32, or is it a signal that the ESP32 will measure? Commented Jun 18, 2020 at 20:50
• @PeterBennett I use a buck converter to provide 3.3v.
– guyd
Commented Jun 19, 2020 at 4:25

0.25 ratio? That's 3v into the ESP at 12V. They are fine, impedance wise, but esp32 has a pretty poor ADC, it samples very fast so gets a lot of noise, and is poor linearity best the extremes of range.

Should divide it more, 12v batteries often go up to 14V or more when charging, and you want to avoid the high end of the ADC.

My advice... 100k, 500k (so divide 6) and a100nF cap across the ADC input and ground as close to the ESP as possible.

• Sounds reasonable and the capacitor is most likely large enough to provide sufficient charge for the ADC sample and hold circuitry, provided that the voltage is not sampled too often (maybe once per second) due to the high resistances. Commented Jun 18, 2020 at 22:04
• For these ADC inputs, high speed of the capacitor is as/more important than the value. Typically ADC sampling capacitors are pF. Commented Jun 18, 2020 at 22:17
• OK, so basic math... 12V battery, with 300+100kohm, gives 30uA current flow. Micro amps. That's going to last a very long time before the battery drains. It's pretty much irrelevant to the battery discharge considering these are solar power batteries. Commented Jun 20, 2020 at 9:23
• In terms of powering the esp32, they take quite a lot of power, of the order of 100-200mA at 3.3V. Through a buck converter, thats going to result in 30-50mA draw at the battery, i.e about 1000x as much as your resistor divider. Commented Jun 20, 2020 at 9:26
• And additionally, your voltage divider is still wrong whether you're asking about it or not... At 14v, you'll be putting 14x100k/(100+300k) which is 3.5V. More than the ESP supply voltage-it will simply read wrong, although with 300k to the 12V you won't damage it. Commented Jun 20, 2020 at 9:40

As commented above, are you trying to power your ESP32 with a 12v battery via a voltage divider?

If so, then a better solution is to use a voltage regulator to regulate your 12v to 3.3v. Even better, you could use a DC-to-DC buck converter for high efficiency.

The voltage difference between 12v and 3.3v is quite high, and a voltage divider is not for supplying power, it is used for signal conditioning.

If your application requires only low current (maybe some uA to few mA), then yes voltage divider could be used. But we know that ESP32 is a power-hungry device, so you'd better off with buck-converter.

• Please see EDIT 1
– guyd
Commented Jun 19, 2020 at 5:10