Skip to content

Instantly share code, notes, and snippets.

@chunkysteveo
Last active June 27, 2022 19:37
Show Gist options
  • Save chunkysteveo/07ed6056db5ab4c02cc3d2df4f0f39ea to your computer and use it in GitHub Desktop.
Save chunkysteveo/07ed6056db5ab4c02cc3d2df4f0f39ea to your computer and use it in GitHub Desktop.
ESP32 C3 Test for the Lilygo ESP01 board for ESPHome. That's the little ESP01 style board from lilygo that has the ESP32C3 chip and optional external antenna. I had to install it first on the Pi's USB port, but now it works fine OTA. Example yaml has various sensors to pick up in HA, and the onboard LED is also a status LED (It's GREEN!) and mon…
substitutions:
display_name: 'ESP32 C3 Test'
device_description: 'ESP32 C3 Test for the Lilygo ESP01 board'
friendly_name: 'ESP32 C3 Test'
device_name: esp32c3-test-new
node_name: esp32c3_test_new
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:
ota:
password: "12345"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot in case wifi connection fails
ap:
ssid: "Esp32C3-Test-New"
password: "12345"
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