ESPhome and USB/serial connection

I read that ESPHome can support serial trough USB connection to upload firmware to ESP32 device,
Unfortunately I can see only the OTA function on the ESPhome GUI in HA.
I already tried to change the USB cable and to replug and restart the add on.
I cannot see anything on the ESP log.
How can I dig in this tissue?

Thank You

How are you running esphome?

I am running hassio on a Pi and ESPhome as add-on in HA.

Compile and export an image of your program from ESPHome to a bin file (click on 3 vertical dots and then Compile).

Download ESPHome Flasher and run.

Plug in a USB cable. Select port from dropdown box.

Select binary file

Flash

Watch log coming via serial port. Is same as the OTA log.

So when you click the top left corner it doesn’t open a drop down menu to select /dev/serial/by-id/…?

If so ha may not be recognizing the device automatically. Maybe reboot with the device plugged in, and see if it turns up in that menu. Otherwise, like the above post mentions you can just compile, download, and flash using a flashing app on a pc. This is what I normally do, because my pi is locked in a box at the back of a closet.

Side note… if you click on /hass.io/system/hardware, it will list all of the usb serial devices seen by ha. If your esp is plugged into the pi, it should show up there and be useable by esphome.

2 Likes

Then the device you want to flash needs to be connected to the Pi

Ok I couldn’t see any USB Device attached to the Pi.
So I dag in and I read that it could be the USB cable even if it worked for other devices and “et voilà” I changed the cable and I could see the USB Device in hassio. So I restarted the add on and I could see th USB Device even in ESPhome add-on.

Thank You for your support

3 Likes

Hi @truglodite and all smart Home Assistant people… This is my first time trying to get ESPhome running…

Seems that Hassio recognises my usb serial…

However, I can’t see it from the ESPhome add-on…

I’ve tried stopping/restarting then uninstalling and re installing the add-on and also rebooting with the device attached. All with no success.

Also, if I want to flash the device directly from my Mac, I am unable to download the binary - the option is greyed out.

image

I have reached the edge of my capability - any other suggestions for me to try?

Hmm that’s kinda weird that it’s showing up by-id but doesn’t seem to be found properly by esphome. In my case, I have a usb-serial device that is known to HA as either/both /dev/ttyUSB0 and /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0… in esphome it is showing up under the dropdown menu as /dev/ttyUSB0 (USB2.0-Serial). Sounds like it might be simpler just to download/flash from your mac… rather than figuring that one out.

Not sure where exactly that greyed out download came from (is this after a failed upload?). When I first flash a device (yes always using my pc) I first hit “Compile” from the hamburger menu, then after it finishes compiling successfully the download button goes from grey to active. Have you tried doing that?

Thanks @truglodite. I’m only a hobbyist and some of this stuff is well above my head but I’m betting that this is something to do with what access the docker container with ESPhome has on my HASS.IO box.

Your response has been very helpful… I had rather stupidly been using the upload option which compiles the binary before failing as I haven’t been able to resolve the USB Serial issue (but interestingly the download option remains greyed out). Using the hamburger menu to compile instead does indeed surface the binary for me to download and I now have my first device up in Home Assistant!

Thankyou!

1 Like

unknowingly

Sometimes it takes me days of banging my head over something before a solution finally occurs to me. Success at the end of a lesson, regardless how long it takes, is what keeps driving me. :wink:

1 Like

The guide explains exactly how to map the usb device https://esphome.io/guides/getting_started_command_line.html#first-uploading

1 Like

Thanks @nickrout. I see the following in the guide;


Unfortunately, I’ve no idea how to apply that to a HASSIO image - I’ve even looked inside of the Portainer HA Addon for clues but sadly with no success.

Any advice on what I’m doing wrong?

My apologies, I missed that you were on hassio and that is the other guide. Which says

Warning
The Hass.io Add-On is currently not capable of discovering new USB ports after the add-on has started due to some docker restrictions. Please go to the add-on details page and restart the add-on if a new USB device is not automatically found. If the USB device is still not found, try changing the USB cable and restarting the add-on.

Or am I just taking you in circles?

@nickrout, No need to apologise.

I did try restarting the add-on as suggested and also uninstalling and reinstalling before finally a reboot of the RPi itself (all with the device attached). Sadly still without success.

Thankfully @truglodite was able to educate me on how to grab the binary files and I can now flash from my Mac.

How do you solve serial connection from Mac?. I have connected Mac to ESP32 but have difficulty to recognise the USB.