Skip to content

[UART] Large deviation between requested and actual baud on ESP32 (Arduino core 3.2.1) — breaks comms #11721

@edwardtfn

Description

@edwardtfn

Board

ESP32-D0WD-V3

Device Description

I'm running tests on a NSPanel (ESP32 - non-variant), but other people reported similar issues on other variants:

Hardware Configuration

https://blakadder.com/nspanel-teardown/

Version

v3.2.1

Type

Bug

IDE Name

VSCode

Operating System

HAOS

Flash frequency

240MHz

PSRAM enabled

yes

Upload speed

921600

Description

When setting a specific UART baud rate on ESP32 with Arduino core v3.2.1, the actual baud rate can significantly diverge from the requested value.
In my case, the issue was observed while running ESPHome 2025.8.0-dev with Arduino v3.2.1 on an ESP32 (NSPanel board).
This divergence causes communication failures with certain peripherals (in my case, a Nextion-like display).


Test results

ESP-IDF (expected behavior)

[16:06:32][C][uart.idf:153]: UART Bus 1:
[16:06:32][C][uart.idf:154]:   TX Pin: GPIO16
[16:06:32][C][uart.idf:155]:   RX Pin: GPIO17
[16:06:32][C][uart.idf:157]:   RX Buffer Size: 256
[16:06:33][C][uart.idf:159]:   Baud Rate: 921600 bps
[16:06:33][C][uart.idf:159]:   Data Bits: 8
[16:06:33][C][uart.idf:159]:   Parity: NONE
[16:06:33][C][uart.idf:159]:   Stop bits: 1
[16:06:33][V][uart.idf:169]:   Actual baud rate: 922190 bps

Offset: +590 (+0.06%)


Arduino core v3.2.1 (problematic behavior)

[16:12:05][C][uart.arduino_esp32:150]: UART Bus 1:
[16:12:05][C][uart.arduino_esp32:151]:   TX Pin: GPIO16
[16:12:05][C][uart.arduino_esp32:152]:   RX Pin: GPIO17
[16:12:05][C][uart.arduino_esp32:154]:   RX Buffer Size: 256
[16:12:05][C][uart.arduino_esp32:156]:   Baud Rate: 921600 bps
[16:12:05][C][uart.arduino_esp32:156]:   Data Bits: 8
[16:12:05][C][uart.arduino_esp32:156]:   Parity: NONE
[16:12:05][C][uart.arduino_esp32:156]:   Stop bits: 1
[16:12:05][V][uart.arduino_esp32:165]:   Actual baud rate: 941176 bps

Offset: +19576 (+2.12%)
The communication with the display failed in this test.


Environment

  • ESP32 board: NSPanel (ESP32 non-variant)
  • Framework: Arduino core v3.2.1
  • Toolchain: xtensa-esp-elf @ 14.2.0+20241119
  • Platform: platform-espressif32 @ 54.03.21-2 (PIO)
  • Host: Built via ESPHome 2025.8.0-dev
    (Not yet tested with a minimal plain-Arduino sketch, but should be straightforward to verify by calling SerialX.baudRate() after begin().)

Suggested minimal test sketch

#include <Arduino.h>

void setup() {
  Serial.begin(115200);
  delay(2000);

  Serial1.begin(921600, SERIAL_8N1, 17, 16); // RX, TX
  delay(100);

  uint32_t actual = Serial1.baudRate();
  Serial.printf("Requested: %u, Actual: %u\n", 921600, actual);
}

void loop() {}

Notes

Tested with 921600, but failed also with other baud rates. It works fine at very low baud rates (like 9600bps)

Sketch

substitutions:
  device_name: kitchen-bench-panel
  friendly_name: Kitchen - Bench - Panel
  wifi_ssid: !secret wifi_ssid
  wifi_password: !secret wifi_password
  BAUD_RATE: '921600'

packages:
  remote_package:
    url: https://github.com/Blackymas/NSPanel_HA_Blueprint
    ref: main
    refresh: 30s
    files:
      - nspanel_esphome.yaml # Base package including TFT transfer

esp32:
  framework: 
    type: arduino

external_components:
  - source: github://pr#10205
    components: [uart]
    refresh: 60s

logger:
  level: VERBOSE

Debug Message

[16:12:05][C][uart.arduino_esp32:150]: UART Bus 1:
[16:12:05][C][uart.arduino_esp32:151]:   TX Pin: GPIO16
[16:12:05][C][uart.arduino_esp32:152]:   RX Pin: GPIO17
[16:12:05][C][uart.arduino_esp32:154]:   RX Buffer Size: 256
[16:12:05][C][uart.arduino_esp32:156]:   Baud Rate: 921600 bps
[16:12:05][C][uart.arduino_esp32:156]:   Data Bits: 8
[16:12:05][C][uart.arduino_esp32:156]:   Parity: NONE
[16:12:05][C][uart.arduino_esp32:156]:   Stop bits: 1
[16:12:05][V][uart.arduino_esp32:165]:   Actual baud rate: 941176 bps

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Peripheral: UARTRelated to the UART peripheral or its functionality.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions