I understand it’s trivial with an ESP8266 but maybe not an Esp32? (From ESP8266 Measuring VCC and this.) “On the ESP8266 you can even measure the voltage the chip is getting”.
Can anyone help me clarify or point me in the right direction if there is a very simple way? I dunno what I’m doing….
While I abandoned the original project, I got back to this for another project and thought I’d drop some more details here as the info I found was a little scattered and confusing for a newbie…
sensor:
- platform: adc
id: solar_plant_batt_voltage
pin: GPIO32
attenuation: auto
name: ${friendly_name} Battery Voltage
update_interval: 1s
accuracy_decimals: 1
filters:
#use moving median to smooth spikes
- median:
window_size: 10
send_every: 10
send_first_at: 10
- delta: 0.1 #Only send values to HA if they change
- throttle: 30s #Limit values sent to Ha
#Convert the Voltage to a battery level (%)
- platform: copy
source_id: solar_plant_batt_voltage
id: solar_plant_batt_level
icon: "mdi:battery"
name: ${friendly_name} Battery Level
unit_of_measurement: '%'
accuracy_decimals: 1
filters:
- calibrate_linear:
# Map from voltage to Battery level
- 0.41 -> 0
- 3.1 -> 100
#Handle/cap boundaries
- lambda: |
if (x < 0) return 0;
else if (x > 100) return 100;
else return (x);
- delta: 0.5 #Only send values to HA if they change
- throttle: 30s #Limit values sent to Ha