Help with UART on ESP32-C6-DevKitC-1

I just tried the 3.3V TX on the WL-134 RFID reader, but this neither worked with the ESP32, nor with the Arduino.

I also tried a voltage divider with a 1kΩ and a 2kΩ resistor in combination with the 5V TX, but this didn’t work either.

I’m really out of ideas…

Let’s take some odds out. Connect Gpio4 to Gpio5 with jumper wire.

logger:
  baud_rate: 0

uart:
  tx_pin: GPIO4
  rx_pin: GPIO5
  baud_rate: 9600
  debug:
    direction: BOTH
    dummy_receiver: true
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_string(direction, bytes);

interval:
  - interval: 10s
    then:
      - uart.write: "Hello World\r\n"

If you don’t get anything received, I don’t know what to think next…

Great idea, this works!
This is the first time I see something on the UART RX of the ESP32 :sweat_smile:

Post some log…

Forget my last reply, I was wrong. In the logs I only see that the ESP32 posted something to TX.

[12:58:24][D][uart_debug:158]: >>> "Hello World\r\n"
[12:58:34][D][uart_debug:158]: >>> "Hello World\r\n"
[12:58:44][D][uart_debug:158]: >>> "Hello World\r\n"
[12:58:54][D][uart_debug:158]: >>> "Hello World\r\n"
[12:59:04][D][uart_debug:158]: >>> "Hello World\r\n"
[12:59:14][D][uart_debug:158]: >>> "Hello World\r\n"
[12:59:24][D][uart_debug:158]: >>> "Hello World\r\n"
[12:59:34][D][uart_debug:158]: >>> "Hello World\r\n"
[12:59:44][D][uart_debug:158]: >>> "Hello World\r\n"

Remove the line
baud_rate: 0
Esphome should configure second UART on your pins.
Post the log when compiling.

Here are my logs:

Logs
INFO ESPHome 2024.12.2
INFO Reading configuration /config/esphome/catdoor.yaml...
WARNING The selected ESP-IDF framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
WARNING The selected ESP-IDF framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
INFO Generating C++ source...
INFO Updating https://github.com/espressif/[email protected]
INFO Compiling app...
Processing catdoor (board: esp32-c6-devkitc-1; framework: espidf; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32C6 160MHz, 320KB RAM, 8MB Flash
 - framework-espidf @ 3.50301.0 (5.3.1) 
 - tool-cmake @ 3.16.9 
 - tool-ninja @ 1.10.2 
 - tool-riscv32-esp-elf-gdb @ 12.1.0+20221002 
 - tool-xtensa-esp-elf-gdb @ 12.1.0+20221002 
 - toolchain-esp32ulp @ 2.35.0-20220830 
 - toolchain-riscv32-esp @ 13.2.0+20240530
Reading CMake configuration...
Dependency Graph
|-- noise-c @ 0.1.6
Compiling .pioenvs/catdoor/src/main.cpp.o
Linking .pioenvs/catdoor/firmware.elf
RAM:   [=         ]  11.5% (used 37596 bytes from 327680 bytes)
Flash: [===       ]  26.3% (used 1033557 bytes from 3932160 bytes)
Building .pioenvs/catdoor/firmware.bin
Creating esp32c6 image...
Successfully created esp32c6 image.
esp32_create_combined_bin([".pioenvs/catdoor/firmware.bin"], [".pioenvs/catdoor/firmware.elf"])
Wrote 0x10c6c0 bytes to file /data/build/catdoor/.pioenvs/catdoor/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/catdoor/firmware.bin"], [".pioenvs/catdoor/firmware.elf"])
========================= [SUCCESS] Took 29.94 seconds =========================
INFO Successfully compiled program.
INFO Connecting to 192.168.1.164 port 3232...
INFO Connected to 192.168.1.164
INFO Uploading /data/build/catdoor/.pioenvs/catdoor/firmware.bin (1033920 bytes)
Uploading: [============================================================] 100% Done...

INFO Upload took 3.23 seconds, waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from 192.168.1.164 using esphome API
INFO Successfully connected to catdoor @ 192.168.1.164 in 4.098s
INFO Successful handshake with catdoor @ 192.168.1.164 in 0.084s
[13:57:46][I][app:100]: ESPHome version 2024.12.2 compiled on Jan 23 2025, 13:57:17
[13:57:46][C][wifi:600]: WiFi:
[13:57:46][C][wifi:428]:   Local MAC: ********
[13:57:46][C][wifi:433]:   SSID: [redacted]
[13:57:46][C][wifi:436]:   IP Address: 192.168.1.164
[13:57:46][C][wifi:439]:   BSSID: [redacted]
[13:57:46][C][wifi:441]:   Hostname: 'catdoor'
[13:57:46][C][wifi:443]:   Signal strength: -58 dB ▂▄▆█
[13:57:46][C][wifi:447]:   Channel: 6
[13:57:46][C][wifi:448]:   Subnet: 255.255.255.0
[13:57:46][C][wifi:449]:   Gateway: 192.168.1.1
[13:57:46][C][wifi:450]:   DNS1: 0.0.0.0
[13:57:46][C][wifi:451]:   DNS2: 0.0.0.0
[13:57:46][C][logger:185]: Logger:
[13:57:46][C][logger:186]:   Level: DEBUG
[13:57:46][C][logger:188]:   Log Baud Rate: 115200
[13:57:46][C][logger:189]:   Hardware UART: UART0
[13:57:46][C][uart.idf:159]: UART Bus 1:
[13:57:46][C][uart.idf:160]:   TX Pin: GPIO4
[13:57:46][C][uart.idf:161]:   RX Pin: GPIO5
[13:57:46][C][uart.idf:163]:   RX Buffer Size: 256
[13:57:46][C][uart.idf:165]:   Baud Rate: 9600 baud
[13:57:46][C][uart.idf:166]:   Data Bits: 8
[13:57:46][C][uart.idf:167]:   Parity: NONE
[13:57:46][C][uart.idf:168]:   Stop bits: 1
[13:57:46][C][captive_portal:089]: Captive Portal:
[13:57:46][C][mdns:116]: mDNS:
[13:57:46][C][mdns:117]:   Hostname: catdoor
[13:57:46][C][esphome.ota:073]: Over-The-Air updates:
[13:57:46][C][esphome.ota:074]:   Address: 192.168.1.164:3232
[13:57:46][C][esphome.ota:075]:   Version: 2
[13:57:46][C][esphome.ota:078]:   Password configured
[13:57:46][C][safe_mode:018]: Safe Mode:
[13:57:46][C][safe_mode:019]:   Boot considered successful after 60 seconds
[13:57:46][C][safe_mode:021]:   Invoke after 10 boot attempts
[13:57:46][C][safe_mode:022]:   Remain in safe mode for 300 seconds
[13:57:46][C][api:140]: API Server:
[13:57:46][C][api:141]:   Address: 192.168.1.164:6053
[13:57:46][C][api:143]:   Using noise encryption: YES
[13:57:47][D][api:103]: Accepted 192.168.1.126
[13:57:47][D][api.connection:1446]: Home Assistant 2025.1.2 (192.168.1.126): Connected successfully
[13:57:51][D][uart_debug:158]: >>> "Hello World\r\n"
[13:58:01][D][uart_debug:158]: >>> "Hello World\r\n"
[13:58:11][D][uart_debug:158]: >>> "Hello World\r\n"
[13:58:21][D][uart_debug:158]: >>> "Hello World\r\n"
[13:58:31][D][uart_debug:158]: >>> "Hello World\r\n"
[13:58:41][D][uart_debug:158]: >>> "Hello World\r\n"

And here is my current config:

Config
esphome:
  name: "catdoor"
  friendly_name: Cat Door

esp32:
  board: esp32-c6-devkitc-1
  flash_size: 8MB
  variant: esp32c6
  framework:
    type: esp-idf
    version: 5.3.1
    platform_version: 6.9.0

uart:
  tx_pin: GPIO4
  rx_pin: GPIO5
  baud_rate: 9600
  debug:
    direction: BOTH
    dummy_receiver: true
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_string(direction, bytes);

interval:
  - interval: 10s
    then:
      - uart.write: "Hello World\r\n"

logger:

api:
  encryption:
    key: "***"

ota:
  - platform: esphome
    password: "***"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.164
    gateway: 192.168.1.1
    subnet: 255.255.255.0
  power_save_mode: none
  ap:
    ssid: "***"
    password: "***"

captive_portal:
    

Ok, now pins 4/5 are set on UART1 and your code looks generally ok.
But I’m not sure where uart.write is writing, UART0 or UART1.

add id to your uart component:
id: bus1
and replace the interval component with this:

interval:
  - interval: 10s
    then:
      - uart.write:
          id: bus1
          data: "Hello World\r\n"
  
1 Like

I have tried this, but got the same result.

Also, I have removed the version definition in my config due to the warning in the logs, but this also didn’t help.

Ok, we have tested on both uarts, different pins etc.
My tool pack is empty.
I think that uart debug simply doesn’t work for C6 on this software version.
Or all your jumper wires are broken… :wink:

1 Like

In this post, the ESP32-C6-DevKitC-1 worked with UART, so I think it should be possible:

@matteor how do your logs looks like? Can you see the UART RX?

It’s slightly different because there is a real device/component.
Yours relies on debug option dummy_receiver.

1 Like

Wow, it worked!!
I have disabled the debugger and used the WL-134 text component:

[21:23:40][D][text_sensor:064]: 'Transponder Code': Sending state '900158002020048'
[21:23:41][D][uart_debug:114]: <<< 00:02:30:44:45:37:37:41:39:43:34:32:34:38:33:30:31:31:30:30:30:30:30:30:30:30:30:30:03:FC:03
[21:23:42][D][text_sensor:064]: 'Transponder Code': Sending state '900158002020048'
[21:23:43][D][uart_debug:114]: <<< 02:30:44:45:37:37:41:39:43:34:32:34:38:33:30:31:31:30:30:30:30:30:30:30:30:30:30:03:FC:03

Here is the config I used:

Config
esphome:
  name: cat-sensor
  friendly_name: Cat Sensor

esp32:
  board: esp32-c6-devkitc-1
  framework:
    type: esp-idf

uart:
  - rx_pin: GPIO4
    baud_rate: 9600
    id: myuart1
    debug:

text_sensor:
 - platform: wl_134
   name: Transponder Code

logger:
  level: DEBUG

api:
  encryption:
    key: "*****"

ota:
  - platform: esphome
    password: "*****"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.131
    gateway: 192.168.1.1
    subnet: 255.255.255.0
  power_save_mode: none
  ap:
    ssid: "*****"
    password: "*****"
captive_portal:

I used the 5V TX in combination with the voltage divider 1kΩ/2kΩ.

Looks like the assumption from @Karosm was correct, and the UART debug doesn’t work with this software version and a ESP32-C6. Thank you very much for your help, I really appreciate it!

Nice! I kind of expected the problem was on debug, not on uart.

1 Like