ESP32-C3_Supermini with LD2420 v2.1 Not Working - UART Fail

Hi everyone, need help troubleshoot an fix the issue where I am not able to make LD2420 v2.1 work with ESP32-C3-Supermini and ESPHOME. I connected the TX and RX pins correctly and ran a test program also using Arduino IDE to check if sensor is good. the sensor responds and sends RAW data when connected and flashed with Arduino IDE HardwareSerial.

However, when i upload the firmware from ESPHome, it says,

[20:03:53][VV][esp32.preferences:071]: nvs_get_blob: key: 233825507, len: 4
[20:03:53][C][safe_mode:079]: There have been 1 suspected unsuccessful boot attempts
[20:03:53][VV][esp32.preferences:040]: s_pending_save: key: 233825507, len: 4
[20:03:53][D][esp32.preferences:114]: Saving 1 preferences to flash...
[20:03:53][VV][esp32.preferences:123]: Checking if NVS data 233825507 has changed
[20:03:53][V][esp32.preferences:126]: sync: key: 233825507, len: 4
[20:03:53][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[20:03:53][I][app:029]: Running through setup()...
[20:03:53][V][app:030]: Sorting components by setup priority...
[20:03:53][VV][scheduler:063]: set_interval(name='', interval=60000, offset=14055)
[20:03:53][C][uart.arduino_esp32:077]: Setting up UART...
[20:03:53][C][ld2420:114]: Setting up LD2420...
[20:03:53][D][ld2420:564]: Sending set config enable command: FF
[20:03:56][E][ld2420:116]: LD2420 module has failed to respond, check baud rate and serial connections.
[20:03:56][E][component:119]: Component ld2420 was marked as failed.
[20:03:56][E][component:164]: Component ld2420 set Error flag: unspecified
[20:03:56][C][wifi:047]: Setting up WiFi...
[20:03:56][C][wifi:060]: Starting WiFi...
[20:03:56][C][wifi:061]: Local MAC: D8:3B:DA:34:B0:90
[20:03:56][V][esp32.preferences:059]: nvs_get_blob('3685851552'): ESP_ERR_NVS_NOT_FOUND - the key might not be set yet
[20:03:56][V][wifi_esp32:066]: Enabling STA.
[20:03:56][ 3193][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
[20:03:56][V][wifi_esp32:485][arduino_events]: Event: WiFi ready
[20:03:56][ 3225][V][WiFiGeneric.cpp:338] _arduino_event_cb(): STA Started
[20:03:56][ 3226][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 2 - STA_START
[20:03:56][V][wifi_esp32:496][arduino_events]: Event: WiFi STA start
[20:03:56][W][wifi_esp32:500][arduino_events]: esp_netif_set_hostname failed: ESP_ERR_INVALID_ARG
[20:03:56][D][wifi:481]: Starting scan...
[20:03:56][VV][scheduler:226]: Running interval '' with interval=60000 last_execution=4294893425 (now=3238)
[20:03:56][W][component:157]: Component wifi set Warning flag: scanning for networks

And I tried other pins also UART1 and UART0 both but same error. here’s my ESPHome YAML code.

esphome:
  name: bedroompresencedetection
  friendly_name: BedroomPresenceDetection

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino


# Enable logging
logger:
  level: VERY_VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "Vrl8Pf0RMKFf+E="

ota:
  - platform: esphome
    password: "25e4a3c3a496aa1"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bedroompresencedetection"
    password: "nbdjkhgfhgd877hdfb7"

captive_portal:

uart:
  id: ubus
  tx_pin: GPIO21  # Change based on your wiring
  rx_pin: GPIO20  # Change based on your wiring
  baud_rate: 115200  # Use 256000 for firmware < v1.5.3
  parity: NONE
  stop_bits: 1   


ld2420:

text_sensor:
  - platform: ld2420
    fw_version:
      name: LD2420 Firmware
sensor:
  - platform: ld2420
    moving_distance:
      name: "Moving Distance"
      id: moving_distance

select:
  - platform: ld2420
    operating_mode:
      name: "Operating Mode"

number:
  - platform: ld2420
    presence_timeout:
      name: "Detection Presence Timeout"
    min_gate_distance:
      name: "Detection Gate Minimum"
    max_gate_distance:
      name: "Detection Gate Maximum"
    gate_select:
      name: "Select Gate to Set"
    still_threshold:
      name: "Set Still Threshold Value"
    move_threshold:
      name: "Set Move Threshold Value"
    gate_move_sensitivity:
      name: "Move Calibration Sensitivity Factor"
    gate_still_sensitivity:
      name: "Still Calibration Sensitivity Factor"

button:
  - platform: ld2420
    apply_config:
      name: "Apply Config"
    factory_reset:
      name: "Factory Reset"
    restart_module:
      name: "Restart Module"
    revert_config:
      name: "Undo Edits"

You could try setting the baud_rate of the logger component to 0 see if the logger is interfering with.

I could not get it to work with gpio 20 and 21, on an esp32-c3, no matter what I tried. Switching to gpio 6 and 7 worked though.

1 Like

It worked for me with the following configuration

esphome:
  name: presencia-despacho
  friendly_name: Presencia Despacho

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_key_presencia

ota:
  - platform: esphome
    password: !secret ota_presencia

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: True
  power_save_mode: NONE
  manual_ip: 
    static_ip: 192.168.1.28
    gateway: 192.168.1.1
    subnet: 255.255.255.0

captive_portal:

uart:
  id: ubus
  tx_pin: GPIO20  # Change based on your wiring
  rx_pin: GPIO21  # Change based on your wiring
  baud_rate: 115200  # Use 256000 for firmware < v1.5.3
  parity: NONE
  stop_bits: 1   


ld2420:

text_sensor:
  - platform: ld2420
    fw_version:
      name: LD2420 Firmware

sensor:
  - platform: ld2420
    moving_distance:
      name : Moving Distance

binary_sensor:
  - platform: ld2420
    has_target:
      name: Presence

select:
  - platform: ld2420
    operating_mode:
      name: Operating Mode

number:
  - platform: ld2420
    presence_timeout:
      name: Detection Presence Timeout
    min_gate_distance:
      name: Detection Gate Minimum
    max_gate_distance:
      name: Detection Gate Maximum
    # See "Number" section below for detail
    gate_select:
      name: Select Gate to Set
    still_threshold:
      name: Set Still Threshold Value
    move_threshold:
      name: Set Move Threshold Value

button:
  - platform: ld2420
    apply_config:
      name: Apply Config
    factory_reset:
      name: Factory Reset
    restart_module:
      name: Restart Module
    revert_config:
      name: Undo Edits

This sensor is garbage. I just bricked three of them trying to calibrate them. my f/w is 1.5.6 and the sequence used was calibrate > apply config > restart module. After about third cycle, it stops responding even after full reboots.

clear

127 / 5.000

Resultados de traducción

Resultado de traducción

I built two that have firmware v1.6.1 and have had them running for 2 months without any issues. Here is a link to my github: https://github.com/JVRMTS/Detectores__Presencia_Esp32C_SuperMini_HomeAssistant

1 Like

It work for me!

NOTE 09/06/2025
Since the 2025.7.2 update, ESPHOME stopped working if updated above that version of ESPHOME. For it to work, with versions equal to or higher than that, you have to change the pins to which the HLK-LD2024 is connected - tx_pin: GPIO07 and rx_pin: GPIO06. With the old configuration, it caused problems with the USB port.