ESP32 S2 and ESPhome upload

You’re correct. It is still the only thing I have not tried. I misunderstood at first and used the code which included the github link but didnt realise there was software. Will try at the weekend

Has anyone actually had success with this yet? I’ve tried everything listed above AFAICT and mine is still just a tiny board sitting there doing nothing

I had no success and just got rid of the boards and got some older ESP32 models. Not saying it is not possible but my coding skills are lacking for such a project.

I bought 5 ESP32 S2 Mini’s like these…

…and had the same problem, not able to flash ready-made bin’s using ESPHome Flasher,
nor from the ESPHome Dashboard and not directly from the browser using https://web.esphome.io.

Turned out ESPTool was the savior.

  1. Installed the latest CP210x driver from here: CP210x USB to UART Bridge VCP Drivers - Silicon Labs (silabs.com)
  2. Downloaded ESPTool for Windows from here Releases · espressif/esptool · GitHub. I used v3.3, the newest version p.t. (4.x) probably works just fine too. Needs no installation. Just unzip it to a folder.
  3. Plugged in the ESP32, a new com port popped up in the device manager under Ports.
  4. Pressed and held the “O” button on the ESP32 then pressed and released the Reset button. Finally I released the “O” button again. I noticed the comport number shown in the Device Manager changed and made a note of the final com-port number.
  5. Opened a Windows Command Prompt window, navigated to the folder where I unpacked ESPTool and ran the following command: esptool -p COM<port number> erase_flash, in my case:
    esptool -p COM7 erase_flash
  6. Did not touch or disconnect anything, opened the ESPHome Dashboard in Home Assistant and clicked “New device” button. Gave it a name, clicked install and selected the COM port number from above (in my case, 7). ESPHome now made its magic and started to flash the ESP32. However, after a while I got an error message from ESPHome. I simply tried one more time, selected the same COM port and this time it was a success. This error on first try happened on all 5, btw, and on all 5 the second try went well.
  7. Pressed the RST button on the ESP32 to take it out of Flash mode, and it came alive in the ESPHome Dashboard.

Not sure if this method works for others, but it worked for me, so at least might be worth a try. I hated the thought of maybe having to throw them away, but now my 5 ESP32 Mini S2s can be put to work and, most importantly, I lost no monetas :slight_smile:

A backup solution might be downloading the .bin file from ESPHome Dashboard and use ESPTool to flash it to the ESP32:

  1. Download a boot_loader for ESP32, i.e. this one: https://github.com/Aircoookie/WLED/releases/download/v0.13.3/esp32_bootloader_v4.bin and put it into the same folder as the ESPTool.
  2. Flash it, then your own .bin file into the ESP32:
1. esptool -p COM<PORT> write_flash 0x0 esp32_bootloader_v4.bin
2. esptool -p COM<PORT> write_flash 0x010000 <bin-filename>.bin
5 Likes

Hi

I’ve tried your methods, but unfortunately they are not working for me.
I’m trying to upload a succesfully compiled program using esptool/esphome/platformio:

My config :

But during upload i’m getting the following errors :

Something goes wrong with the .bin files, i’ve manually added this “patched_bootloader.bin”, just by copying a normal ESP32 bootloader and renaming it into the specific folder, but without results unfortunately.

What files do I exactly need to upload? Only the factory-firmware.bin? Ive tried your method just by only uploading the firmware.bin file after flashing the bootloader, but without result unfortunately.

Anyone who can help me out in the right direction?

I used the following suggestion from this post and it seems to work fine:

esp32:
  board: lolin_s2_mini
  variant: ESP32S2
  framework:
    type: arduino
    version: 2.0.3
    platform_version: 5.0.0
5 Likes

No luck for me on a Win11 PC, Windows won’t find a driver to load for the ESP32 and says the device isn’t working. I’ve tried all the silabs variants for Windows.

When the ESP32 is plugged in with no buttons pressed, it appears as a new drive (odd?). If I plug in while the “O” button is pressed it appears in Device Manager under “other devices” with no drivers and in a non-working state.

I connected my S2 to the box running HA and ESPHome for the initial load and had no issues.

1 Like

Did you try the specific sequence here?
https://www.wemos.cc/en/latest/tutorials/s2/get_started_with_arduino_s2.html#upload-code

1 Like

Did you first install the CP210x driver (item 1 in the list)?
Did you connect the board without any buttons pressed (item 3) and then press the buttons in the order given in item 4 in the list?

Thanks @olealm, yes - I installed the drivers (the VCP one, as well as trying the others). Looks like Win11 eventually gave up on me messing with USB ports - after a reboot I was able to complete steps 1-5. Step 6 (which has to be via web.esphome.io as I’m on a Win11 PC and not my HASSIO server) fails with esphome saying it only supports ESP8266 or ESP32.

This at least proved the device was active, so I created a new config on ESPHome then downloaded the .bin file and followed your backup instructions to flash it. The flashing worked but the S2 mini didn’t appear to do anything after that - no lights, no wifi connection etc.

@Mahko_Mahko I followed the code download sequence as shown there.

Next I tried connecting it to my HASSIO server (RPi4) directly as @gaz99 suggested and tried downloading. The device is identified on the RPi and compile completes, but download fails with an error:

ERROR Running command failed: [Errno 32] Broken pipe
ERROR Please try running esptool.py --before default_reset --after hard_reset --baud 460800 --port /dev/ttyACM0 --chip esp32s2 write_flash -z --flash_size detect 0x10000 /data/esp32-s2-01/.pioenvs/esp32-s2-01/firmware.bin 0x1000 /data/cache/platformio/packages/framework-arduinoespressif32/tools/sdk/esp32s2/bin/bootloader_dio_80m.bin 0x8000 /data/esp32-s2-01/.pioenvs/esp32-s2-01/partitions.bin 0xe000 /data/cache/platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin locally.

This happens whether or not O button is pressed on boot.

1 Like

Ok, so hopefully you have gotten a few steps further down on the road to success!
For step 6 I used this setting in the ESPHome sketch (not sure if it actually matters, but might be worth a try):

esp32:
  board: esp32-s2-saola-1
  framework:
    type: esp-idf

Later on I have changed the esp32 setting it to the one from @gaz99 above and updated wirelessly with no issues.

Yes I tried that board config along with other suggestions. Any use of the esp-idf framework gives me an error - didn’t write this one down, but it indicated this framework is not supported for the board type.

I only have one of these boards to play with, so can’t discount it may be faulty. Will go back to my other ESP32’s for now - my initial reason for trying this one was to test the ADC range as I’ve found the ADC on the Wemos ESP32 mini is 0 - 1.04V and I wanted a small form factor ESP32 that supported 0 - 3.2V.

that’s what resistors are for.

Ok. If you happen to have this Wemos D1 Mini ESP32 board it looks like the ADC range can be set in firmware.

Yes I knew someone would point that out :slight_smile: . Agreed but it does up the component count & complexity when you’re using multiple ADCs.

Thanks @olealm that’s the one I have (a few of) - I had no idea that was an option! Will read up on how to update that.

So easy to implement ADC attenuation settings once you know where to look! This detail is not listed (or referenced) under the ESPHome ESP32 entry, but is included under the general ADC settings which I should have re-read when moving from ESP8266 to ESP32.

1 Like

So has anyone managed to actually get this working? I am able to flash the s2 using the web flasher. (cannot get it to flash with windows one.( i do the button compination, holding 0 while inserting usb then press once the rst and when it gets recognized again from pc I remove my hand from the 0. But it just never connects to wifi or when I loaded a status led, still doesnt do anything. I have installed a simple led blind/flash with arduino IDE and it works! Just need to reset the board after you have flashed it. I have like 6 off them and waiting for another 6 to arrive ahahah. I really though it was too good to be true (price and size)
the code I have tried is:

esphome:
name: test
esp32:
board: lolin_s2_mini
variant: ESP32S2
framework:
type: arduino
version: 2.0.5 also tried 2.0.3
platform_version: 5.2.0 also tried 5.0.0

Here is a sample configuration file that is working for me, but I’ve also tested with the newest versions (arduino 2.05 and platform 5.2.0) for other ESP32S2 boards and it also works.
I think what fixed my problems was the “platform options” settings.

esphome:
  name: $devicename
  platformio_options:
    board_build.f_flash: 40000000L
    board_build.flash_mode: dio
    board_build.flash_size: 4MB

esp32:
  board: adafruit_qtpy_esp32s2
  variant: esp32s2
  framework:
    type: arduino
    version: 2.0.3
    platform_version: 4.3.0

yes couldn’t get it work either. However below does work but is not in arduino framework so there some issue with binary sensor templating

esp32:
board: lolin_s2_mini
variant: ESP32S2
framework:
type: esp-idf
platform_version: GitHub - jhamhader/platform-espressif32: Espressif 32: development platform for PlatformIO