Skip to content

Instantly share code, notes, and snippets.

@chunkysteveo
Created August 28, 2022 15:00
Show Gist options
  • Save chunkysteveo/05e8e4e3c83490d43870da36ea26ed20 to your computer and use it in GitHub Desktop.
Save chunkysteveo/05e8e4e3c83490d43870da36ea26ed20 to your computer and use it in GitHub Desktop.
ESP32 C3 Test for the Lilygo T-01 Plus board for ESPHome. That's the ESP C3 board from lilygo with the 16340 battery. Example yaml has various sensors to pick up in HA, and the onboard LED is also a status LED (It's GREEN!) IO3.
substitutions:
display_name: 'ESP32 C3 Lilygo T01 Plus'
device_description: 'ESP32 C3 Test for the Lilygo T01 Plus board'
friendly_name: 'ESP32 C3 Lilygo T01 Plus'
device_name: lilygo-t01-plus
node_name: lilygo_t01_plus
esphome:
name: ${device_name}
platformio_options:
board_build.flash_mode: dio
comment: ${device_description}
on_boot:
- priority: 800.0
then:
- component.update: ${node_name}_uptime_raw
- component.update: wifisignal
esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf
platform_version: 3.3.2
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "ENTER_YOUR_KEY_HERE"
ota:
password: "OTA_PASSWORD_HERE"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot in case wifi connection fails
ap:
ssid: "Lilygo-T01-Plus Fallback Hotspot"
password: "AP_PASSWORD_HERE"
light:
- platform: status_led
name: "Onboard LED"
pin: GPIO3
id: esp32c3_onboard_led
icon: mdi:led-off
effects:
- strobe:
- strobe:
name: Strobe Fast
colors:
- state: true
duration: 100ms
- state: false
duration: 100ms
- strobe:
name: Heartbeat
colors:
- state: true
duration: 100ms
- state: false
duration: 100ms
- state: true
duration: 100ms
- state: false
duration: 1000ms
button:
- platform: restart
name: ${display_name} restart
text_sensor:
- platform: wifi_info
ip_address:
name: ${display_name} IP Address
ssid:
name: ${display_name} Connected SSID
bssid:
name: ${display_name} Connected BSSID
- platform: template
name: ${friendly_name} Uptime
id: ${node_name}_uptime
icon: mdi:clock-start
binary_sensor:
- platform: status
name: ${display_name} Status
sensor:
- platform: wifi_signal
name: ${display_name} WiFi Singal Strength
id: wifisignal
update_interval: 120s
- platform: uptime
name: "${friendly_name} Uptime Sensor"
id: ${node_name}_uptime_raw
update_interval: 60s
on_raw_value:
then:
- logger.log:
format: "Raw Value of Uptime sensor: %f, %f"
args: ['id(${node_name}_uptime_raw).raw_state', 'id(${node_name}_uptime_raw).state']
level: INFO
- text_sensor.template.publish:
id: ${node_name}_uptime
state: !lambda |-
int seconds = round(id(${node_name}_uptime_raw).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m " : "") +
(to_string(seconds) + "s")
).c_str();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment