Skip to content

ESPHome

Created: 2023-12-17 18:09:57 -0800 Modified: 2023-12-17 18:27:05 -0800

It’s a system to control microcontrollers. I went from never even having heard of it to having my microcontroller up and running in <90 minutes (that was while streaming, so times are generally inflated).

I got this microcontroller (“Wireless Module CH340 CP2102 NodeMcu V3 V2 Lua WIFI Internet of Things Development Board Based ESP8266 ESP-12E”) for 2and10[capacitivetouchbuttons](https://www.aliexpress.com/item/3256805794972004.html)for2 and 10 [capacitive touch buttons](https://www.aliexpress.com/item/3256805794972004.html) for 1.

Its pinout is (reference):

Note: I used the 3.3V-out pin for the capacitive button.

  • Note: you need to flash the microcontroller with it connected directly to your computer the first time. After that’s done, you can use the Docker container and do everything over Wi-Fi.
  • I installed via pip3 (just needed “pip3 install esphome”)
  • Given the microcontroller that I bought (ESP8266 ESP-12E NodeMcu), I needed to use the NodeMCU 1.0 (ESP-12E Module) configuration.
  • I went through the wizard and the documentation and got the device flashed. This is somewhat of a “now draw the rest of the owl” step because I had to hide a lot of what I was doing off-screen for this and didn’t take notes. 😢
  • After that, I disconnected it from my computer and plugged it in to a USB-to-wall adapter.
  • To launch the web interface through Docker:
    • cd <directory containing the YAML files elsewhere in this note>
    • docker run —rm -p 6052:6052 -e ESPHOME_DASHBOARD_USE_PING=true -v ”${PWD}”:/config -it ghcr.io/esphome/esphome
    • Navigate to http://localhost:6052
    • You can edit the secrets using the button at the upper right.
    • You can edit the YAML for a particular device and then update it over Wi-Fi.

Here’s my config.yaml for my microcontroller. When you touch the button, it hits a URL, and when you hold it, it hits a different URL:

esphome:
name: testeroni
esp8266:
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret device_password
ota:
password: !secret device_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Testeroni Fallback Hotspot"
password: !secret fallback_wifi_password
http_request:
useragent: esphome/device
timeout: 10s
binary_sensor:
- platform: gpio
pin: 5
name: "Lights"
on_multi_click:
- timing:
- ON for at least 1s
then:
- http_request.get: http://nfc2.bot.land:3000/bedroomoff
- timing:
- ON for at most 1s
then:
- http_request.get: http://nfc2.bot.land:3000/bedroomon
captive_portal:

Then, my secrets.yaml (saved alongside config.yaml) looks like this:

device_password: hunter2
wifi_ssid: my_wifi
wifi_password: hunter2butonline
fallback_wifi_password: somerandomlygeneratedthingthatIneverneeded