ESPHome on ESP32 as Bluetooth Proxy

ESPHome on ESP32 as Bluetooth Proxy

Na osnovu tekstova po internetu, poverovao sam da ću stvar završiti za 5 minuta. I tako bi možda i bilo, iako ne verujem, ali recimo, da sam koristio Linux računar ili da mi je Home Assistant instaliran na brzom računaru a ne na malom sporaću RPi3.

Ali pošto sam ja samo običan čovek sa običnim Windows računarom, mene je na svakom koraku dočekalo neko iznenađenje koje mi je uglavnom objašnjavalo zašto nešto nije moguće uraditi.

Prvo drajveri za ESP32 i Windows

Make sure you have the right drivers installed. Below are the drivers for common chips used in ESP devices:

CP2102 drivers: CH342, CH343, CH9102 drivers on manufacturer’s website: CH340, CH341 drivers manufacturer’s website:

CH9102 chip

Neko je predložio CDC drajvere, ali meni su na kraju i SER drajveri proradili normalno.

Windows CDC driver: Windows SER driver:


ESP32-WROOM-32 or ESP-WROOM-32D (2018)

32D is new module

Hello Phil, the D version is the updated module and recommended for new designs in Espressif Product Ordering Guide, it uses the 5x5mm ESP32 package inside, that allows a different internal routing than the non-D. The antenna design has also changed. The result is better RF performance. If you can switch to the D, you may want to do so, otherwise you can go on with the non-D. From a fw standpoint it does not make any difference. But looking at scalability, the 8M, 16M and U versions are all derivatives of the D. Thank you for using Espressif.

Flashing ESPHome on ESP32-WROOM-32 with CH9102X

USB to Serial Port, USB to UART chip, USB to UART bridge, adapter

Drajveri, 1. dobar kabl 2. sačekaš, pa restart I morau Chrome - i sve radi Adapt - pripremi za obacivanje u ESPHome Sada možeš skinuti sa računara ali i sa chrome browsera Onaj ga vidi zatim i sve tamo radiš dalje online

Driver: CH343SER The ESP32 which uses this chip also doesnt use normal button function as far as I can tell (in my very limited experience).

Flash method on esphome in Home Assistant:

The only way to succesfully flash is to hold the boot button down for the duration of the flash. Wait for the message which indicates the device has attempted to reset itself. The flash will hang at this point.

Then let go of the boot button, and shortly after click the EN button once.

Then wait for download to complete.

Its possible this is all completely obvious and thats how you are supposed to carry out a flash - but either way the driver listed and steps above worked for me consistently on two of these ESP32 CH9102X boards bought at different times from different sellers.

Both boards happily working with Home Assistant Glow. One tracking my total house power usage at the meter, and the other one tracking incoming power generated by my wind turbine.

Integrations are working and just waiting for the energy dashboard to update. But its midnight, and I’m having a celebratory glass of single malt and going to bed.

Nothing is really easy in Smart Home world

Flashing ESP inside Home Assistant

RPi3: Too Slow

The easiest way to flash ESP devices is probably by using ESPHome within Home Assistant. However, I encountered my first problem, which is that my RPi3 is a very slow device and the flashing process takes too long.

I may be able to wait for it in the future, when I don’t need it done urgently, but I am currently looking for an efficient solution - and that surely does not include running ESPHome on Home Assistant on my slow RPi3.

So, as reprogramming ESPHome is so slow when done on RPi3, I decided to switch to using Windows command line on my laptop.

Flashing ESP from Windows command-line

Windows: Cannot build firmware due the whitespaces

I often now use terminal in Windows because since I’ve been utilizing amazing scoop package manager, I don’t mind installing Python, PIP or anything else, as I know that scoop will confine them within their portable folders. So, I started installing the ESPHome tool in Windows with enthusiasm.

pip install wheel esphome
esphome version

By now, everything looked like it was working as expected and as predicted. With the help of the CLI documentation from here: Command Line Interface, I continued typing.

esphome wizard esphome.yaml
> Enter: esp32-bt-proxy, ESP32, esp32dev, WiFi credentials

After the basic YAML file esphome.yaml was successfully created, we need to compile the flash image based on that file.

esphome run esphome.yaml

The first time it took two minutes of “preparation” before it began updating, but it was faster afterwards. It could be OTA flashed over WiFi network, but in some cases it simply has to be done via USB port, mostly when changing partition table.

*** Update ipak nije brzinski šampion jer skoro uvek traje oko 5 minuta

Quirks of BT Proxy Firmware

Bluetooth Proxy feature is very common and possibly the most frequently used ESPHome’s application.

The easiest way to flash the ESP32 using ESPHome is through the web tool called ESPHome Bluetooth Proxy, which only works on Chrome. Once this is done, you can adjust the YAML configuration if necessary.

The tool first writes a “blank” firmware to the ESP32, making it “adoptable” when viewed from the ESPHome dashboard in Home Assistant. From there, you can continue to configure it within HA.

The best example YAML file for a generic ESP32 used as a Bluetooth proxy can be found in the same repository: bluetooth-proxies/esp32-generic.yaml.

This file typically looks like this:

    name: esp32-bt-proxy
    comment: ESP32 primarily acting as a Bluetooth Proxy
  board: esp32dev
    type: esp-idf
    interval: 1100ms
    window: 1100ms

  active: true

Although I am not certain that this is necessary, I connected the device via USB again just to be safe. I came across information that suggested it is required:

When switching from arduino to esp-idf, make sure to update the device with a serial cable as the partition table is different between the two frameworks as OTA Update Component updates will not change the partition table.

Just when I thought I had completed the final step, I encountered a problem with the build step not being able to proceed Specifically, I received the error message “Error: Detected a whitespace character in project paths”. Knowing what this meant, I optimistically moved the Python installation to a folder that had no whitespace in its name:

scoop uninstall –purge python scoop install –global python

However, this did’nt work either, as it appears that the ESP-IDF library from Expressif has an issue with “No whitespace characters allowed in project paths”, as stated here."

Try that again, but in WSL

WSL2: Cannot flash via USB

So I switched to WSL. I already have Python installed here and I believed that there wouldn’t be any surprises. Well, almost :)

Instead of a smooth experience, I’m welcomed by the fact that my “~/.local/bin” was not in the PATH and that’s precisely where “esphome” package is installed. And, as if I wanted to make it more difficult for myself, I realized that I was using ZSH as my shell, so my .profile wasn’t loaded and therefore the proper PATH wasn’t set. Oh well, for ZSH, I can run:

emulate sh -c 'source ~/.profile'

Maybe I will even add a line to .zprofile for future issues:

echo "[[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile'" >> .zprofile

So now, ZSH processes my .bashrc just like Bash does.

All that remains is to actually add the PATH to the .bashrc. Go to your home directory again and open the .bashrc file. Then copy-pasting this will add the desired line at the end of .bashrc file:

echo 'export PATH="$PATH:~/.local/bin"' >> .bashrc

I’m tired of this. Ok. Let’s continue. I must logout and login again and PATH will be updated properly.

Finally, after all this hassle, Python is now working properly in WSL, let’s move on…

I copied the YAML file to WSL and ran esphome run esp32-my-config.yaml. This time it successfully completed. Bravo! :(

New Obstacle: The Lack of USB Support in WSL2

After building the firmware image, it now needs to be written to the device.

And as usual, another obstacle popped up here: WSL2 does not support USB ports! There are some “simple” solutions for this, but since I had almost given up and their “simplicity” seemed complicated to me, I decided to take the shortest path to completing the task.

I decided to run the beautiful official little flasher tool: esphome/esphome-flasher. There is no installation, just download it from releases and run it. As firmware file select “firmware.bin” that WSL created and in my case is located in the folder .\.esphome\build\esp32-bt-proxy\.pioenvs\esp32-bt-proxy\firmware.bin.

Prvo pokreneš “esphome compile …” pa to snimiš sa ESL flasher (da ga prebaciš u onaj drugi mod)

A posle će raditi iz WSL sve normalno jer ide preko WiFi

Da bi video ESP32 uređaj unutar ESPHome u HA, samo iskopiraj YAM fajl u /config/esphome i HA će sam sve ukapirati. Inače, kao podsetnik, nije moguće “izvući” YAML iz uređaja kasnije, jer je pravac jednosmeran.

Ozbiljno drkanje je za ESPHome

dorssel/usbipd-win: Windows software for sharing locally connected USB devices to other machines, including Hyper-V guests and WSL 2. and there is a GUI for that by Andrew Leech at GitLab: alelec/wsl-usb-gui

USB device sharing system over IP network

Updating your ESPHome Firmware on ESP32

Let’s say a new version of ESPHome has just come out and you have to flash it over USB.

To make sure you don’t waste your time, first check which version you have with:

esphome version

Cool. Let’s give updating a try:

pip3 install -U esphome
esphome version

You have to do everything all over again, first build (compile) and then flash. My YAML file was already saved here and I didn’t have any changes to it, since I’m just putting in a newer firmware. So, compile by typing:

esphome run esp32-bt-proxy.yaml

I’m getting all of this done in WSL since there’s no hiccups there. But after that, I gotta step out of WSL and flash it on Windows with the GUI tool I mentioned earlier. On Windows, extract the firmware.bin file from the depths of WSL, from a folder like build\...\.pioenvs\...\firmware.bin and flash it in the tool ESPHome-Flasher.exe. It’s pretty speedy now - thankfully!

CO2 Sensor

Jedini kompletni izvor za YAML je odavde: SCD30 – after hours coding, pa sam shvatio:

i2c: sda: 21 scl: 22 scan: true id: only_i2c_bus


  • platform: scd30

    i2c_id: only_i2c_bus

    co2: name: “Penthouse CO2” accuracy_decimals: 1 temperature: name: “Penthouse Temperature” accuracy_decimals: 2 humidity: name: “Penthouse Humidity” accuracy_decimals: 1

Ako imaš problem sa pinovima na ESP8266 -

On update, ESPHome esp32-bt-proxy failed to compile

So I swiched to “arduino”: Try to compile your project with arduino framework as it’s been working fine on esp32 for quite some time now.

Source: ESP32-IDF framework fails to compile on ARMv7 · Issue #3076 · esphome/issues

ESPHome Voice Assistant

It’s official: $13 voice remote for Home Assistant - Home Assistant

It is too quiet!

ATOM Echo Smart Speaker Development Kit | m5stack-store

m5stack/ATOM-ECHO m5-docs

C008-C Atom Echo Development Tool

firmware/voice-assistant/m5stack-atom-echo.yaml at main · esphome/firmware · GitHub

date 16. Jan 2022 | modified 29. Dec 2023
filename: » ESPHome as Bluetooth Proxy