I want to hook 3 modbus adapters to an esp32doit-devkit-v1. The problem that Serial0 is used by logging. Hardware uart is changeable, but it has to be one of Serial0, Serial1, Serial2.
using SoftwareSerial is not an option for now due to external modbus library not supporting it
What are my options? Will setting logger to NONE completely disable interaction with Serial0, or will I still get som interference ?
Looking at the code here it looks like the Arduino framework will only setup UART0 on the default RX/TX pins. The ESP-IDF framework looks to me like it will let the three UART be setup to any compatible GPIO pins. With the logger baud rate set to 0, none of the esphome log output will go to the UART but logs still available via wifi. The esp bootloader will typically output some diagnostic text over the default UART0 RX/TX pins, if this is problematic for your MODBUS device then the ESP-IDF framework can be used to assign different pins for UART0.
Here was some test code. On a dev board, U1 TX is jumpered to U2 RX, U2 TX jumpered to U3 RX, and U3 TX jumpered to U1 RX. Pressing the button in the UI, causes the test message to get sent from U1 and looped backed via U2 and U3. Changing the framework to ardunio will break the example unless one of the uart pins are set to default 1 and 3.
Oh wow, that is so fantastic. Thank for such analysis will check it out!. Currently I’ve just removed the logging, seems to work, but having them available via wifi would be beneficial
Hello
I know this post it’s old, but I have same problem. I can’t use 3 uarts in my ESP32 WROOM with ESPHOME.
I’m very happy when I see your post… I think it’s the solution … but it don’t work.
With framework arduino I get this error :
[10:11:15][C][uart.arduino_esp32:077]: Setting up UART...
[10:11:15][ 39][E][HardwareSerial.cpp:525] setRxBufferSize(): RX Buffer can't be resized when Serial is al[C][uart.arduino_esp32:077]: Setting up UART...
With Esp-idf framework I get this error :
[14:08:37]x40080400,len:4
[14:08:37]load:0x40080404,len:3876
[14:08:37]entry 0x4008064c
[14:08:37]I (29) boot: ESP-IDF 5.1.5 2nd stage bootloader
[14:08:37]I (29) boot: compile time Feb 26 2025 12:55:55
[14:08:37]I (29) boot: Multicore bootloader
[14:08:37]I (34) boot: chip revision: v3.1
[14:08:37]I (37) boot.esp32: SPI Speed : 80MHz
[14:08:37]I (42) boot.esp32: SPI Mode : DIO
[14:08:37]I (46) boot.esp32: SPI Flash Size : 4MB
[14:08:37]I (51) boot: Enabling RNG early entropy source...
[14:08:37]I (56) boot: Partition Table:
[14:08:37]I (60) boot: ## Label Usage Type ST Offset Length
[14:08:37]I (67) boot: 0 otadata OTA data 01 00 00009000 00002000
[14:08:37]I (75) boot: 1 phy_init RF data 01 01 0000b000 00001000
[14:08:37]I (82) boot: 2 app0 OTA app 00 10 00010000 001c0000
[14:08:37]I (90) boot: 3 app1 OTA app 00 11 001d0000 001c0000
[14:08:37]I (97) boot: 4 nvs WiFi data 01 02 00390000 0006d000
[14:08:37]I (105) boot: End of partition table
[14:08:37]I (109) boot: No factory image, trying OTA 0
[14:08:37]I (114) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=2f7f0h (194544) map
[14:08:37]I (181) esp_image: segment 1: paddr=0003f818 vaddr=3ffb0000 size=00800h ( 2048) load
[14:08:37]I (182) esp_image: segment 2: paddr=00040020 vaddr=400d0020 size=a10fch (659708) map
[14:08:37]I (386) esp_image: segment 3: paddr=000e1124 vaddr=3ffb0800 size=0331ch ( 13084) load
[14:08:37]I (390) esp_image: segment 4: paddr=000e4448 vaddr=40080000 size=15b04h ( 88836) load
[14:08:38]I (434) boot: Loaded app from partition at offset 0x10000
[14:08:38]I (437) boot: Set actual ota_seq=1 in otadata[0]
[14:08:38]I (437) boot: Disabling RNG early entropy source...
[14:08:38]I (451) cpu_start: Multicore app
[14:08:38]I (451) cpu_start: Pro cpu up.
[14:08:38]I (451) cpu_start: Starting app cpu, entry point is 0x40081cd0
[14:08:38]I (0) cpu_start: App cpu up.
[14:08:38]I (469) cpu_start: Pro cpu start user code
[14:08:38]I (469) cpu_start: cpu freq: 160000000 Hz
[14:08:38]I (469) cpu_start: Application information:
[14:08:38]I (474) cpu_start: Project name: esp-audio-mp3
[14:08:38]I (479) cpu_start: App version: 2024.12.2
[14:08:38]I (484) cpu_start: Compile time: Feb 26 2025 12:54:29
[14:08:38]I (490) cpu_start: ELF file SHA256: 113736d38ced704f...
[14:08:38]I (496) cpu_start: ESP-IDF: 5.1.5
[14:08:38]I (501) cpu_start: Min chip rev: v0.0
[14:08:38]I (506) cpu_start: Max chip rev: v3.99
[14:08:38]I (511) cpu_start: Chip rev: v3.1
[14:08:38]I (516) heap_init: Initializing. RAM available for dynamic allocation:
[14:08:38]I (523) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
[14:08:38]I (529) heap_init: At 3FFB7EE0 len 00028120 (160 KiB): DRAM
[14:08:38]I (535) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
[14:08:38]I (541) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
[14:08:38]I (548) heap_init: At 40095B04 len 0000A4FC (41 KiB): IRAM
[14:08:38]I (555) spi_flash: detected chip: generic
[14:08:38]I (559) spi_flash: flash io: dio
[14:08:38]I (563) app_start: Starting scheduler on CPU0
[14:08:38]I (568) app_start: Starting scheduler on CPU1
[14:08:38]I (568) main_task: Started on CPU0
[14:08:38]I (578) main_task: Calling app_main()
[14:08:38]033[0;32m[I][logger:171]: Log initialized
[14:08:38][C][safe_mode:079]: There have been 0 suspected unsuccessful boot attempts
[14:08:38][D][esp32.preferences:114]: Saving 1 preferences to flash...
[14:08:38][D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[14:08:38][I][app:029]: Running through setup()...
[14:08:38][C][uart.idf:093]: Setting up UART 1...
[14:08:43]E (5734) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
[14:08:43]E (5734) task_wdt: - loopTask (CPU 0)
[14:08:43]E (5734) task_wdt: Tasks currently running:
[14:08:43]E (5734) task_wdt: CPU 0: loopTask
[14:08:43]E (5734) task_wdt: CPU 1: IDLE1
[14:08:43]E (5734) task_wdt: Aborting.
[14:08:43]E (5734) task_wdt: Print CPU 0 (current core) backtrace
[14:08:43]
[14:08:43]
[14:08:43]
[14:08:43]
[14:08:43]Backtrace: 0x400f5b21:0x3ffbf740 0x400eda99:0x3ffbf770 0x400dac79:0x3ffbf7b0 0x400dad5e:0x3ffbf7f0 0x40165cfd:0x3ffbf810 0x40165d57:0x3ffbf830 0x400e0bdc:0x3ffbf850 0x400e22d1:0x3ffbf890 0x400d7ae3:0x3ffbf970
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x400f5b21: uart_ll_rxfifo_rst at /data/cache/platformio/packages/framework-espidf/components/hal/esp32/include/hal/uart_ll.h:248
(inlined by) uart_hal_rxfifo_rst at /data/cache/platformio/packages/framework-espidf/components/hal/uart_hal_iram.c:25
WARNING Decoded 0x400eda99: uart_param_config at /data/cache/platformio/packages/framework-espidf/components/driver/uart/uart.c:712 (discriminator 2)
WARNING Decoded 0x400dac79: esphome::uart::IDFUARTComponent::setup() at /data/build/esp-audio-mp3/src/esphome/components/uart/uart_component_esp_idf.cpp:100
WARNING Decoded 0x400dad5e: non-virtual thunk to esphome::uart::IDFUARTComponent::setup() at /data/build/esp-audio-mp3/src/esphome/components/uart/uart_component_esp_idf.h:14
WARNING Decoded 0x40165cfd: esphome::Component::call_setup() at /data/build/esp-audio-mp3/src/esphome/core/component.cpp:78
WARNING Decoded 0x40165d57: esphome::Component::call() at /data/build/esp-audio-mp3/src/esphome/core/component.cpp:104
WARNING Decoded 0x400e0bdc: esphome::Application::setup() at /data/build/esp-audio-mp3/src/esphome/core/application.cpp:38
WARNING Decoded 0x400e22d1: setup() at /data/build/esp-audio-mp3/src/main.cpp:311
WARNING Decoded 0x400d7ae3: esphome::loop_task(void*) at /data/build/esp-audio-mp3/src/esphome/components/esp32/core.cpp:67
[14:08:43]
[14:08:43]
[14:08:43]
[14:08:43]
[14:08:43]ELF file SHA256: 113736d38ced704f
[14:08:43]
[14:08:43]Rebooting...
[14:08:44]ets Jul 29 2019 12:21:46
[14:08:44]
[14:08:44]rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[14:08:44]configsip: 0, SPIWP:0xee
[14:08:44]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[14:08:44]mode:DIO, clock div:1
[14:08:44]load:0x3fff0030,len:7112
[14:08:44]load:0x40078000,len:15624
[14:08:44]load:0x40080400,len:4
[14:08:44]load:0x40080404,len:3876
[14:08:44]entry 0x4008064c