October 10, 2025, 05:06:05 PM

ESPHome issue with UART

Started by ju, October 03, 2025, 11:26:32 AM

Previous topic - Next topic

ju

Hi folks!

So I've been scratching my head a lot the past day or so, maybe someone here can help me out!

I have a working ESPHome project running on an Olimex ESP32-POE-16MB Rev. L1, I don't need POE for this, nor do I need the Ext connector, so I decided to try to move the project to an Olimex ESP32-Gateway-EA Rev. I
I don't use Ethernet on either board.

Since I changed boards, I cannot get UART to work at all.

I used GPIO13 for TX and GPIO5 for RX on the ESP32-POE without issues.
On the ESP32-Gateway, I've so far tried GPIO16&17, GPIO12&13, GPIO4&13: I don't get any response from UART anywhere.
I've used the same cable for both boards, and now switched back to the ESP32-POE, still the same cable, and everything still works on that board.

Is there something I need to do to make UART work on the ESP32-Gateway?

Thanks a lot!

LubOlimex

Try with GPIO16 and GPIO32, pins #11 and #13 from CON1. Make sure to define them in the code for UART operation.

Did you use the esp32-gateway for board config?
Technical support and documentation manager at Olimex

ju

Thanks for the suggestion!
Yes, I've used esp32-gateway as a board config, with esp-idf as a framework.

For a moment there, I thought you had saved me! On my first attempt I could see *something* on the UART RX, garbled noise, but something!
But upon further inspection, it was just a bad solder joint causing intermittent connection.
Reseating a resoldering them got me back to my initial issue: I can TX, I have no idea if the other end receives anything, and I do not RX anything... :-/

LubOlimex

Did you try with simplest UART test? Just create the software serial on the chosen pins and then connect them together (e.g. RX to TX) and then open terminal and see if you get echo when you type something. If there is echo the problem is not with the esp32-gateway.

If there is still a problem, maybe test with Arduino IDE instead. I haven't used esphome a lot but in Arduino IDE serial works. Here is some simple test with instructions for Arduino IDE:

/*
  ESP32-GATEWAY Serial Demo
  -------------------------
  Demonstrates using a second UART on GPIO11 (TX) and GPIO13 (RX).

  ESP32 Arduino package installation:
  1. Open Arduino IDE → File → Preferences
  2. In "Additional Boards Manager URLs" add:
      https://espressif.github.io/arduino-esp32/package_esp32_index.json
  3. Go to Tools → Board → Boards Manager
  4. Search for "esp32" and install the package by Espressif Systems
  5. Select your board under:
      Tools → Board → ESP32 Arduino → "Olimex ESP32-Gateway"

 
  Hardware connections:
  - GPIO11 → TX2 (connect to RX of other device)
  - GPIO13 → RX2 (connect to TX of other device)
  - USB → for Serial Monitor (primary UART)
*/

#define RX2_PIN 13  // Receive pin for Serial2
#define TX2_PIN 11  // Transmit pin for Serial2

void setup() {
  // Start USB serial monitor at 115200 baud
  Serial.begin(115200);
  while (!Serial) {
    ; // Wait for Serial Monitor to open
  }
  Serial.println("ESP32-Gateway Serial2 demo starting...");

  // Initialize Serial2 on GPIO13 (RX) and GPIO11 (TX) at 9600 baud
  Serial2.begin(9600, SERIAL_8N1, RX2_PIN, TX2_PIN);
  Serial.println("Serial2 initialized on GPIO11 (TX) / GPIO13 (RX)");
}

void loop() {
  // Send test message periodically via Serial2
  Serial2.println("Hello from ESP32-Gateway Serial2!");

  // If data is received on Serial2, display it on the USB serial monitor
  if (Serial2.available()) {
    String incoming = Serial2.readStringUntil('\n');
    Serial.print("Received on Serial2: ");
    Serial.println(incoming);
  }

  // Echo any text entered in the Serial Monitor to Serial2
  if (Serial.available()) {
    String input = Serial.readStringUntil('\n');
    Serial2.print("Echo from USB: ");
    Serial2.println(input);
  }

  delay(2000); // Delay 2 seconds between transmissions
}

Let me know if the problem persists with Arduino IDE.
Technical support and documentation manager at Olimex

ju

Sorry for the delay, I was only able to test now!
Here's the output on the serial monitor:

rst:0x8 (TG1WDT_SYS_RESET),boot:0x1a (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4744
load:0x40078000,len:15672
load:0x40080400,len:3152
entry 0x4008059c
ESP32-Gateway Serial2 demo starting...
Serial2 initialized on GPets Jul 29 2019 12:21:46

rst:0x8 (TG1WDT_SYS_RESET),boot:0x1a (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4744
load:0x40078000,len:15672
load:0x40080400,len:3152
entry 0x4008059c
ESP32-Gateway Serial2 demo starting...
Serial2 initialized on GPets Jul 29 2019 12:21:46

rst:0x8 (TG1WDT_SYS_RESET),boot:0x1a (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4744
load:0x40078000,len:15672
load:0x40080400,len:3152
entry 0x4008059c
ESP32-Gateway Serial2 demo starting...
Serial2 initialized on GPets Jul 29 2019 12:21:46

rst:0x8 (TG1WDT_SYS_RESET),boot:0x1a (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4744
load:0x40078000,len:15672
load:0x40080400,len:3152
entry 0x4008059c
ESP32-Gateway Serial2 demo starting...
Serial2 initialized on GPets Jul 29 2019 12:21:46

rst:0x8 (TG1WDT_SYS_RESET),boot:0x1a (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4744
load:0x40078000,len:15672
load:0x40080400,len:3152
entry 0x4008059c
ESP32-Gateway Serial2 demo starting...
Serial2 initialized on GPets Jul 29 2019 12:21:46

So, I don't think it's working as expected, right?

LubOlimex

Until board resets it works fine, but why does it reset? Is it resetting by itself? If so test with another shorter USB cable and port. Maybe this cable is flawed and doesn't make good contact with the board or doesn't provide enough power.

If you didn't reset it, did you open serial terminal on the COM port of board? Connect GPIO11 and GPIO13 together after you open the terminal and type something to see if it will return echo.
Technical support and documentation manager at Olimex

ju

This is the same 1m USB-C (65w rated) cable I use for everything, but I tried with a 30cm USB-A->C with the same result.

I don't do anything, I plug the board and the (continuously repeating) serial output is what I've pasted!

LubOlimex

Haha, mystery solved, so this is expected outcome! I made a mistake in the code sorry about that. We wrote above about pin #11 and #13 and in the code I defined GPIO11 and GPIO13 which was the mistake. It should be  GPIO16 and GPIO32, my bad I mixed the consequent number of the header and the GPIO number.

I will update the code, test and give you updated code soon.
Technical support and documentation manager at Olimex

LubOlimex

#8
Yes, just change:

#define RX2_PIN 32  // Receive pin for Serial2
#define TX2_PIN 16  // Transmit pin for Serial2

And it will work fine, connect pin #11 and #13 together (to establish simple echo test) then open serial terminal from Tools -> Serial Monitor and you can send something and you will receive it back after some delay (can be reduced by reducing delay(2000); in the code).

For example, I sent 1234 and this is what I got before during and after transmition:

Received on Serial2: Hello from ESP32-Gateway Serial2!

Received on Serial2: Echo from USB: 1234

Received on Serial2: Hello from ESP32-Gateway Serial2!

Edit: If you don't have a wire between #11 and #13 (aka GPIO16 and GPIO32) you won't receive neither Echo nor "Hello..." message!
Technical support and documentation manager at Olimex

ju

Yep, that works better  ;D
It takes a few seconds to get the echo output however (I'd say 5 or 6 seconds).
Is that normal?

And that leaves us with the ESPHome problem, any idea why the same code works fine on a ESP32-POE, and not with ESP32-Gateway?

LubOlimex

Maybe the configuration or template for ESP32-GATEWAY is wrong. Maybe some other obscure bug. Can't say anything specifically. My advice is to contact the ESPHome community and team. Post in the forums, write an e-mail, point to this thread.

Maybe try some other template, some generic ESP32 template.
Technical support and documentation manager at Olimex

ju

I tried with esp32dev as well, but same results :-/
I'll try the ESPHome community forums, but I don't expect much...