LD2420 fails after OTA update

I have a strange issue on a few of my esp devices where after I update the code and upload it over OTA the LD2420 sensor fails.

The sensor starts working after I unplug the USB and plug it back again (energy cut).

This happens on various devices (esp32-c6, S3, regular esp32)

substitutions:
  name: office-stairs-sensor
  friendly_name: Office Stairs Sensor

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: '1.0'
  on_boot:
    priority: 250
    then:
      - wait_until:  
          condition:
            wifi.connected: 
          timeout: 5s

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

logger:
  level: VERBOSE

api:
  encryption:
    key: "XXX"

ota:
  - platform: esphome
    password: "XXX"

wifi:
  networks:
  - ssid: !secret wifi_ssid
    password: !secret wifi_password
  - ssid: !secret wifi_ssid2
    password: !secret wifi_password2

captive_portal:

improv_serial:

uart:
  tx_pin: GPIO6
  rx_pin: GPIO5
  baud_rate: 115200
  parity: NONE
  stop_bits: 1

ld2420:

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

sensor:
  # - platform: wifi_signal
  #   name: "WiFi Signal"
  #   update_interval: 3s
  - platform: ld2420
    moving_distance:
      name : Moving Distance
    
binary_sensor:
  - platform: ld2420
    has_target:
      name: Presence

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

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

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

light:
  - platform: esp32_rmt_led_strip
    name: "On board LED"
    num_leds: 1
    pin: GPIO8
    rgb_order: GRB
    chipset: ws2812
    rmt_symbols: 48
  - platform: esp32_rmt_led_strip
    id: led_accent
    rgb_order: GRB
    is_rgbw: true
    chipset: SK6812
    pin: GPIO7
    num_leds: 24
    name: "Main light"
    rmt_symbols: 48

I have the same error. Still have not figured out how to make it work again.

[00:09:29][W][ld2420:211]: Firmware version v0.0.0 and older supports Simple Mode only
[00:09:29][E][component:141]:   ld2420 is marked FAILED: unspecified

Solved: Changed the framework type from arduino to esp-idf. Now ut works like it used to.

I’m not sure that it’s related to framework because I’m already on esp-idf and still get the same error.

Happy that you have solved yours tho :fist_right: :fist_left:

I’m also seeing the same behaviour.

Using a xiao-esp32c3. I have framework type set to esp-idf. I don;t experience this with the LD2010C.

I’ll try to use another ld2420 to see if its the sensor that’s defective.

# Wiring 
# esp32-c3 -> ld2420
# 3.3v -> 3.3v
# GND -> GND
# D10 (tx) -> rx
# D1(rx) - > OT1 (tx)
# D2 - > OT2
# You can use other GPIO pins for UART then D7 and D6 which interfere with the USB UART


esphome:
  name: esphome-web-9dbb90 
  friendly_name: presence-sensor-basement
  min_version: 2025.5.0
  name_add_mac_suffix: false

esp32:
  board: seeed_xiao_esp32c3
  variant: esp32c3
  framework:
    type: esp-idf

# Enable logging
logger:
  baud_rate: 0

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  domain: .local
  fast_connect: true

ota:
  platform: esphome
  password: !secret ota_password

api:
  encryption:
    key: !secret api_encryption_key
  reboot_timeout: 60s

esp32_ble_tracker:
  max_connections: 3


bluetooth_proxy:
  active: true
  connection_slots: 3

uart:
  id: ld2420_uart
  tx_pin: GPIO10
  rx_pin: GPIO3
  baud_rate: 115200
  parity: NONE
  stop_bits: 1

Hi!

I used the same sensor with an esp32-c6 and no longer saw the problem.

I tried another ld2420 on the esp32-c3 ( the one with the original issue ) and still experienced the same problem.

I’ll run the esp32-c6 for a bit and see how it behaves.

I Got it working LD2420 - ESP32C3 SuperMini ( Ali Express)

I had the same issue and spent nearly a week trying to get it working. I’m using the ESP32-C3 Super Mini (HW-466AB), which I purchased from AliExpress.

For some reason, the board was still holding on to the previous firmware or sketch, even when flashing it using esptool.py.

Here’s what finally worked for me:

  1. Hold down the BOOT button
  2. While still holding BOOT, press and release the RESET button
  3. Release the BOOT button

Once that was done, I uploaded the config via USB and did a power cycle.(Unplug and replug)

To my great surprise it showed the firmware version

23:01:58][C][ld2420:187]: LD2420:
[23:01:58][C][ld2420:187]:   Firmware version:  v1.6.1

I have also been using external usb power for stable power.


esphome:
  name: presence-sensor--ld2420--espc3
  friendly_name: Presence Sensor - LD2420 - ESPC3
  platformio_options:
    upload_speed: 921600
    board_build.flash_mode: dio

esp32:
  board: esp32-c3-devkitc-02
  variant: ESP32C3
  framework:
    type: arduino
    
# Enable logging
logger:
  baud_rate: 0

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

ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.50.15
    gateway: 192.168.50.1
    subnet: 255.255.255.0
    dns1: 192.168.50.1
  reboot_timeout: 20min
  fast_connect: True
  power_save_mode: NONE



uart:
  id: ld2420_uart
  tx_pin: GPIO21
  rx_pin: GPIO20
  baud_rate: 115200
  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
1 Like

Hey @svdennis good to hear :clap: and thanks for the explanation and the time you put in.

Does the LD2420 still work after you upload anything over OTA? Or do you also have to unplug/plug power in order for it to work?

Hey @rgnyldz
It fails!
Yeah thats thing, unless I do a hard reset and not to ota it works.
The minute I update via OTA . It fails!!!

I was happy that I got it work!
I got excited a little too early!:slightly_frowning_face:

Still looking to find a solution.

Same issue here. The OTA works and the ESP32-c3 gets updated, but as soon as it tries to boot it fails. On a physically restart, it workds with the updated version of the configuration.

It only happens via “Wirelessly”. USB plug works fine.

I use Arduino frame work and it works just fine for me, ESP32 Dev Kit C

esphome:
  name: bathroom-sensor
  friendly_name: Bathroom Sensor

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:

api:
  encryption:
    key: ""

ota:
  - platform: esphome
    password: "ddd1e0ac8c1b4f495f0c0ed23e3f31db"

wifi:
  ssid: ""
  password: ""

  ap:
    ssid: "Bathroom-Sensor Fallback Hotspot"
    password: "lm9DMvI8oRIr"

captive_portal:

uart:
  id: ld2410_uart
  tx_pin: 1
  rx_pin: 3
  baud_rate: 256000
  parity: NONE
  stop_bits: 1
  debug:
    direction: BOTH
    dummy_receiver: false
    after:
      delimiter: [0xF8]

ld2410:
  uart_id: ld2410_uart

binary_sensor:
  - platform: ld2410
    has_target:
      name: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target
    out_pin_presence_status:
      name: Out Pin Presence Status

sensor:
  - platform: ld2410
    light:
      name: Light
    moving_distance:
      name: Moving Distance
    still_distance:
      name: Still Distance
    moving_energy:
      name: Move Energy
    still_energy:
      name: Still Energy
    detection_distance:
      name: Detection Distance
    g0:
      move_energy:
        name: g0 Move Energy
      still_energy:
        name: g0 Still Energy
    g1:
      move_energy:
        name: g1 Move Energy
      still_energy:
        name: g1 Still Energy
    g2:
      move_energy:
        name: g2 Move Energy
      still_energy:
        name: g2 Still Energy
    g3:
      move_energy:
        name: g3 Move Energy
      still_energy:
        name: g3 Still Energy
    g4:
      move_energy:
        name: g4 Move Energy
      still_energy:
        name: g4 Still Energy
    g5:
      move_energy:
        name: g5 Move Energy
      still_energy:
        name: g5 Still Energy
    g6:
      move_energy:
        name: g6 Move Energy
      still_energy:
        name: g6 Still Energy
    g7:
      move_energy:
        name: g7 Move Energy
      still_energy:
        name: g7 Still Energy
    g8:
      move_energy:
        name: g8 Move Energy
      still_energy:
        name: g8 Still Energy

number:
  - platform: ld2410
    timeout:
      name: Timeout
    light_threshold:
      name: Light Threshold
    max_move_distance_gate:
      name: Max Move Distance Gate
    max_still_distance_gate:
      name: Max Still Distance Gate
    g0:
      move_threshold:
        name: g0 Move Threshold
      still_threshold:
        name: g0 Still Threshold
    g1:
      move_threshold:
        name: g1 Move Threshold
      still_threshold:
        name: g1 Still Threshold
    g2:
      move_threshold:
        name: g2 Move Threshold
      still_threshold:
        name: g2 Still Threshold
    g3:
      move_threshold:
        name: g3 Move Threshold
      still_threshold:
        name: g3 Still Threshold
    g4:
      move_threshold:
        name: g4 Move Threshold
      still_threshold:
        name: g4 Still Threshold
    g5:
      move_threshold:
        name: g5 Move Threshold
      still_threshold:
        name: g5 Still Threshold
    g6:
      move_threshold:
        name: g6 Move Threshold
      still_threshold:
        name: g6 Still Threshold
    g7:
      move_threshold:
        name: g7 Move Threshold
      still_threshold:
        name: g7 Still Threshold
    g8:
      move_threshold:
        name: g8 Move Threshold
      still_threshold:
        name: g8 Still Threshold

The work around I currently use is and it seems to be working,
Once I do the OTA, I unplug the ESP32, hold the RST button and plug the cable in, this seems to send the data correctly to home assistant.
Since I have the 3D case printed, I had no way to have the RST button out all the time.
I used a toothpick as a temporary work around :smile:

Thanks man! that saved me many hours of debugging!

1 Like