Indeed, the leads were reversed. But simply swap them for reference. I guess the person assembled this doesnt have a clue.
Yes I read the adc with different code. Let’s say a different platform because I have it ported to esphome. For example:
substitutions:
devicename: "airgradient"
upper_devicename: "Airgradient"
voltage_divider: "4.27238" #Battery input 119k resistor
battery_warning_voltage: "3.6"
battery_low_voltage: "3.2"
- platform: adc
pin: A0
name: "${upper_devicename} Battery Voltage"
id: batv
filters:
- multiply: ${voltage_divider}
- sliding_window_moving_average:
window_size: 10
send_every: 10
on_value:
- sensor.template.publish:
id: battery_percentage
state: !lambda |-
int batper = (x - ${battery_low_voltage}) / (4.2 - ${battery_low_voltage}) * 100;
if(batper > 100) { batper = 100; }
if(batper < 0) { batper = 0; }
return batper;
disabled_by_default: true
update_interval: 1s
entity_category: diagnostic
- platform: template
name: "${upper_devicename} Battery Percentage"
id: battery_percentage
device_class: battery
accuracy_decimals: 0
unit_of_measurement: "%"
entity_category: diagnostic