I would like to display the current battery charge level on my ESP32-S3 Board Lilygo T4 S3.
It comes with a 3.7V lipo battery connector.
I have ESPHome (display+touch) running with the following code:
# Test Script
substitutions:
comment: "Lilygo T4-S3 Sandbox"
device_name: lilygo-t4-s3
friendly_name: Lilygo T4-S3
# Variables
esphome:
name: ${device_name}
friendly_name: ${friendly_name}
comment: ${comment}
esp32:
board: esp32-s3-devkitc-1
flash_size: 16MB
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "..."
ota:
- platform: esphome
password: "..."
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Lilygo-T4-S3 Fallback Hotspot"
password: "..."
# Lilygo T4 S3 Configuration
spi:
id: quad_spi
type: quad
clk_pin: 15
data_pins: [14, 10, 16, 12]
i2c:
sda: 6
scl: 7
touchscreen:
- platform: cst226
id: my_touchscreen
interrupt_pin: 8
reset_pin: 17
font:
- file: "gfonts://Roboto"
id: font_std
size: 40
glyphs: "!\"%()+=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz/\\[]|&@#'"
- file: "gfonts://Roboto@700"
id: font_title
size: 40
glyphs: "!\"%()+=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz/\\[]|&@#'"
display:
- platform: qspi_dbi
model: RM690B0
data_rate: 80MHz
spi_mode: mode0
dimensions:
width: 450
height: 600
offset_width: 16
color_order: rgb
invert_colors: false
brightness: 255
cs_pin: 11
reset_pin: 13
enable_pin: 9
#update_interval: never
auto_clear_enabled: false
# Define Pages
pages:
- id: page_1
lambda: |-
it.print(it.get_width()/2, it.get_height()/2-20, id(font_title), TextAlign::CENTER, "Battery Charge");
it.print(it.get_width()/2, it.get_height()/2+20, id(font_std), TextAlign::CENTER, "29%");
psram:
mode: octal
speed: 80MHz
# ---
captive_portal:
Anybody experience how to display the charge level using ESPHome? I watched some youtube videos talking about voltage divider and stuff but it is not specifically for ESPHome (https://youtu.be/osAOdmZuvDc?si=qV1ncidQEoZWBP8m)