I have a DFRobot Firebeetle V3.0 ESP32 board.
The board comes with a battery power option and ability to measure battery voltage.
From the board schematic:
When I setup ADC on A0 with 2x multiplier I get wildly fluctuating values.
Anywhere from 0.28V to 2V.
I’ve read that ESP32 ADCs are not the greatest, but I think I’m just getting garbage readings…
YAML code:
sensor:
- platform: adc
pin: A0 # Analog input pin (GPIO 36/ A0)
name: "Battery Voltage"
id: battery_voltage
accuracy_decimals: 2
update_interval: 120s
attenuation: 12db # Allows reading up to ~3.9V
samples: 1
filters:
- multiply: 2.0 # Adjust based on your voltage divider ratio
on_value:
then:
- lambda: |-
ESP_LOGW("adc_sensor", "Voltage is %.2f V", id(battery_voltage).state);
Think I found a solution…
The 1M-ohm resistors are too high.
I’m guessing the are high to reduce the battery current draw as much as possible but this leads to ADC problems.
Replaced the 1M with 100K-ohm and all is good now.
Getting accurate readings.
I’m guessing there is some way to calculate the optimal resistor value based on capacitance of ADC circuit, etc…