LILYGO TTGO T5 V2.3 2.13 Inch E-Paper Display - How to get battery readings?

Im using the LILYGO TTGO T5 V2.3 2.13 Inch E-Paper display in my first HA project and I learned a lot from experimenting and altering this repo: https://github.com/kotope/esphome_eink_dashboard

Is there a way to read the battery level of the 2.13" display like it is done with the 4.7" display in the linked repo? I can see that there is a battery component for that one but it doesn’t seem to work for my display.

Did you find a way to read the battery level?

I’ve been beating my head at this for days, and finally found a solution, so I figured I would share it here for future visitors and past.

Funnily enough, the core tipoff was here: ESPHome adc scatter is too big - #13 by nikito7

That block almost directly works as is, but I will provide mine here for reference as I add some extra information.

sensor:
  - platform: adc
    pin: GPIO35
    name: "Battery Voltage"
    update_interval: 30s
    accuracy_decimals: 3
    attenuation: auto # auto is recommended, otherwise 11db
    filters:
      - multiply: 1.84
    id: battery_voltage
    entity_category: diagnostic
    unit_of_measurement: 'V'
    device_class: voltage

  - platform: template
    name: "Battery Percentage"
    update_interval: 30s
    accuracy_decimals: 2
    lambda: |-
      return (id(battery_meeting_info_voltage).state - 3.5) / 0.7 * 100.00;
    id: battery_percentage
    entity_category: diagnostic
    unit_of_measurement: '%'
    device_class: battery

For the Percentage formula, I get mixed information on 3.3 or 3.5 being 0%. I believe 3.3 is the minimum for the ESP32 to function at all. But depending on the battery, like a LIPO, you might not want it to get that low.

We know that 4.2 is the max on a full charge. So if you change it to 3.3 or something lower than 3.5, change the 0.7 to the difference between the new number and the 4.2 max (4.2-3.5=0.7) so that your percentage is the right value.

3 Likes