open sesame
The Idea
I have a spare ESP32C6 laying around and a garage door opener with two spare pins for opening and closing the garage door. In my last post I wrote:
As im hosting my homeassistant on my Raspberry Pi 3, I cant flash the ZigBee firmware, because my RP3 will OOM kill the process. Somewhere in the future, I´ll change my hosting over to my small EliteDesk G3.
Luckily I didnt have to change my hosting over to my EliteDesk G3 because I found another way to circumvent the RAM limitation during the flashing process.
Prerequisite
Im using a Windows maschine as my daily driver. Some of the edits/changes are easier on linux, thats why I have a WSL2 Ubuntu installation. You can skip the next step when you are already on a UNIX system.
WSL2
- open Powershell as an admin
- run
wsl --install(maybe windows prompts you to activate some features) - when prompted -> restart you PC
- get you WSL2 installation updated:
sudo apt update && sudo apt upgrade -y
ESPHome install
- install Python and dependecies:
sudo apt install python3-pip python3-venv libvenv-dev -y - create a temporary virtual env.:
python3 -m venv esphome_venv - and activate the workspace:
source esphome_venv/bin/activate - install ESPHome:
pip install esphome
USB passthrough
When pluggin in you ESP32 into your host maschine (e.g my windows maschine) WSL2 can´t see new hardware by default. So we have to bridge the connection
On your Windows PC:
- open Powershell as an admin
- install usbipd-win:
winget install --interactive usbip-win - connect your ESP32 via USB
- list devices to find its ID:
usbipd list
example output:
PS C:\Windows\system32> usbipd list
Connected:
BUSID VID:PID DEVICE STATE
1-3 0c45:652f USB-Eingabegerät Not shared
1-4 9886:002c Astro A50 Voice, Astro A50 Game, USB-Eingabegerät Not shared
1-5 046d:c07d USB-Eingabegerät Not shared
1-8 256f:c635 USB-Eingabegerät Not shared
1-11 0000:0002 Unbekanntes USB-Gerät (Fehler beim Anfordern einer Geräte... Not shared
1-12 2341:8037 Arduino Micro (COM3), USB-Eingabegerät Not shared
1-13 1e71:2017 USB-Eingabegerät Not shared
1-14 8087:0032 Intel(R) Wireless Bluetooth(R) Not shared
3-1 303a:1001 Serielles USB-Gerät (COM6), USB JTAG/serial debug unit Not shared
for me its BUSID 3-1. note the STATE: "Not shared". To share the USB device with our WSL install we have to bind to it, like so: usbipd bind --busid BUS_ID where BUS_ID is 3-1 for me. usbipd bind --busid 3-1
example output:
PS C:\Windows\system32> usbipd list
Connected:
BUSID VID:PID DEVICE STATE
1-3 0c45:652f USB-Eingabegerät Not shared
1-4 9886:002c Astro A50 Voice, Astro A50 Game, USB-Eingabegerät Not shared
1-5 046d:c07d USB-Eingabegerät Not shared
1-8 256f:c635 USB-Eingabegerät Not shared
1-11 0000:0002 Unbekanntes USB-Gerät (Fehler beim Anfordern einer Geräte... Not shared
1-12 2341:8037 Arduino Micro (COM3), USB-Eingabegerät Not shared
1-13 1e71:2017 USB-Eingabegerät Not shared
1-14 8087:0032 Intel(R) Wireless Bluetooth(R) Not shared
3-1 303a:1001 Serielles USB-Gerät (COM6), USB JTAG/serial debug unit Shared
And attach it to WSL: usbipd attach --busid BUS_ID --distribution Ubuntu
WSL2 Linux Terminal
Check if your bridged hardware appears with the following command: ls /dev/tty*
example output:
ikameo@Win11:~$ ls /dev/tty*
/dev/tty /dev/tty16 /dev/tty24 /dev/tty32 /dev/tty40 /dev/tty49 /dev/tty57 /dev/tty8 /dev/ttyS6
/dev/tty0 /dev/tty17 /dev/tty25 /dev/tty33 /dev/tty41 /dev/tty5 /dev/tty58 /dev/tty9 /dev/ttyS7
/dev/tty1 /dev/tty18 /dev/tty26 /dev/tty34 /dev/tty42 /dev/tty50 /dev/tty59 /dev/ttyACM0
/dev/tty10 /dev/tty19 /dev/tty27 /dev/tty35 /dev/tty43 /dev/tty51 /dev/tty6 /dev/ttyS0
/dev/tty11 /dev/tty2 /dev/tty28 /dev/tty36 /dev/tty44 /dev/tty52 /dev/tty60 /dev/ttyS1
/dev/tty12 /dev/tty20 /dev/tty29 /dev/tty37 /dev/tty45 /dev/tty53 /dev/tty61 /dev/ttyS2
/dev/tty13 /dev/tty21 /dev/tty3 /dev/tty38 /dev/tty46 /dev/tty54 /dev/tty62 /dev/ttyS3
/dev/tty14 /dev/tty22 /dev/tty30 /dev/tty39 /dev/tty47 /dev/tty55 /dev/tty63 /dev/ttyS4
/dev/tty15 /dev/tty23 /dev/tty31 /dev/tty4 /dev/tty48 /dev/tty56 /dev/tty7 /dev/ttyS5
my ESP32 appeard as /dev/ttyACM0
YAML file
Now you have to make a choice: create the YAML file in your WSL Linux installation, or create it under Windows and move it to WSL. I explain both.
Linux:
touch garage_door.yaml you can choose any file name
nano garage_door.yaml
Add your YAML code. You can find my a bit further down.
Windows:
- create a text file, add the YAML code, and change the extension of the file to .yaml
- move the file to you WSL directory. To do so: type this in your explorer address bar and drag and drop your file
\\wsl$\Ubuntu\home\yourusername\
example YAML file:
esphome:
name: esp32_c6_button
esp32:
board: esp32-c6-devkitc-1
variant: esp32c6
framework:
type: esp-idf
wifi:
ssid: "WIFI NAME"
password: "PASSWORD"
# Enable logging
logger:
api:
encryption:
key: "GENERATE ONE WITH THE CODE BELOW"
ota:
platform: esphome
password: "YOUR_OTA_PASSWORD"
button:
- platform: template
name: "Garagentor"
icon: "mdi:garage"
on_press:
- switch.turn_on: relay_1
- delay: 2s
- switch.turn_off: relay_1
switch:
- platform: gpio
id: relay_1
pin: GPIO18
inverted: false
internal: true
Encryption key:
openssl rand -base64 32
Compile and Flashing
With your ESP32 attached and the YAML ready, run this in your WSL2 terminal:
esphome config garage_door.yaml
esphome run garage_door.yaml
When done you should be able to see and use your programmed ESP32 in homeassistant




