ESP32 S2 Mini and UARTs **solved**

its been a Looooong road… but I finally got these chips to compile AND flash w/ naitive ESPHome when using UARTs. I actually have three hardware UARTs defined. what a nightmare…

esphome:
  name: ${device_name}
  comment: ${device_description}
  platformio_options:
    board_build.extra_flags:
      - "-DARDUINO_USB_CDC_ON_BOOT=0"  # Override, defaults to '-DARDUINO_USB_CDC_ON_BOOT=1'     
esp32:
  board: featheresp32-s2
  framework:
    type: arduino
    version: 2.0.3
    platform_version: 4.4.0

Notice both the chip definition (this was key) and extra_flags AND platform version. No other combination works, compiles AND wireless logs work. I hope this helps someone else out there…

2 Likes

@jazzmonger Thank you for posting this! I am struggling with getting 2 UARTS to work on a Lolin ESP32 S2 Mini board.

I have a LD2410 and a PM1006 - both needing a UART - connected to the ESP32s2 and only one of the two works at any one time. On a Wemos ESP32 WROOM Mini board I was told that I needed to use pins 1 & 3 (native uart0 pins) for one of my uarts in order to be able to use all 3 otherwise only 2 would work on the Arduino framework. The problem with the S2 mii board is that uart0 pins are not exposed so I can’t do that. If the same rule applies then I can only use a single uart.

The flag you posted helped me get over the CDC error however the version and platform doesn’t seem to help. Do you have any other suggestions other than using a Wemos ESP32 Mini board (on order in case all fails with S2)?

I wish I did. I{m Done using variants, Too many issues. My new go to board is a ESP32 D1 mini.

@jazzmonger Yup, I ended up replacing the ESP32-S2 mini board with the one you use and it all worked but it is a bit too big so the build is far from the tidy layout I was hoping for. The s2 has compelling features like the fact that there are no default pins for functionality but its support in esphome seems incomplete or limited compared to the regular ESP32 at this point :frowning:

Hi @jazzmonger,
Would you mind telling me which UART you used to flash (using esptool) your ESP32-S2?
As was mentioned by @aruffell, the default pins for UART0 (GPIO34&GPIO44 - ESP32-S2-WROOM UART1 & UART0 pins definition · Issue #466 · espressif/esp-at · GitHub) are not brought out to a header.

Regards, Martin

It’s not ESPHomes limitations… it’s the S2 chip itself! Keep looking for a small board that works that isn’t an S2 variant!

Hmmm…well, the S2 board I used had a mini USB port built into it. I can only assume it was tied to the default flashing UART pins on the chip. After all the hassles and countless hours and days I spent chasing all the problems I had with that chip variant, I literally threw all my S2 chips away and stopped using them-lesson learned. It was a interest idea for a chip, but VERY poorly executed.

The ESP32 D1 mini is now my go-to general purpose Dev board. It’s tiny and has no limitations, most Dev boards with the ESP32 WROOM chip (no variant) on them should work without issues. Keep that in mind when looking for a Dev board to buy.

Jeff

Hey guys, I got one of the UARTs working on the s2 mini! Here are the relevant snippets from my config:

esphome:
  name: theater-presence
  friendly_name: Theater Presence
  platformio_options:
    board_build.extra_flags:
      - "-DARDUINO_USB_CDC_ON_BOOT=0"
esp32:
  board: lolin_s2_mini
  framework:
    type: arduino
    #version: 2.0.3
uart:
  - id: my_uart
    rx_pin: GPIO39 #marked as RXD on WEMOS ESP32S2 D1
    tx_pin: GPIO37 #marked as TXD
    baud_rate: 256000
    stop_bits: 1
    parity: NONE
ld2410:
  id: ld2410_radar
  uart_id: my_uart

This is from a combo sensor using LD2410 and AHT20.

1 Like

Thank you so much!! This finally worked for me!
My s2 mini previously only connected to wifi when disconnecting my modbus device.

Hi
i use different pins for uart have been working for year for Energy Meter

#######################
#### Hardware Code ####
#######################
esp32:
  board: esp32-s2-saola-1
  framework:
    type: arduino

uart:
  tx_pin: GPIO11 #TX
  rx_pin: GPIO12 #RX
  baud_rate: 9600
  stop_bits: 1

Sorry you guys had so many problems with the S2. I know there are a few quirks with them but once you figure those out these are nice little helpers. I use them for all my UART “jobs” because of their size and price.

  1. To program first time. Press BOOT&RESET at the same time and release RESET but keep BOOT pressed until upload starts!
  2. Use Adafruits online Web ESPTool programmer to upload code in chrome or edge.
  3. Use the following code in your yaml.
esp32:
  #board: esp32-s2-saola-1
  board: lolin_s2_mini
  variant: esp32s2
  framework:
    type: arduino

uart:
  tx_pin: GPIO2
  rx_pin: GPIO3
  baud_rate: 115200
  id: uart_bus

I hope this is helpful. Cheers RT.


Trying to get this figured out.
I am using a ESP32-S2-MINI and CH340X. USB is detected, flashing works fine, and everything works as expected.
If I make a test Arduino sketch, Serial works fine without setting any pins.
When I upload ESPhome, I get the boot message from Serial, but no log at all after that.
I have tried what suggested i this thread but still can’t get any log.

To answer my own question, I figured it out.

I noticed in the wifi log the board sets up as log: USB_CDC

I looked through the docs Logger Component — ESPHome and ESP32-S2 pins for USB_CDC are 19/20.

Maybe there is another way to do this, but this is what I did and it works.

esp32:
board: esp32-s2-saola-1
framework:
type: arduino

logger:
hardware_uart:
UART0

When adding a board the first time in ESPHome, you will have to do it manually by first creating the board, then edit, then upload.