ESP32. – selecting resistors for voltage divider

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.

Best Answer

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.