LD2420 Configures but behaves strangely

As the title suggests I have configured a LD2420 24GHz radar presence sensor via ESPHome (which is running through the HomeAssistant add-on which is running on a Pi 3 1Gb).


I have the sensor wired up with to ESP8266 (a NodeMCU 1.0) which is currently connected via USB to the Pi running home assistant.

I’m pretty much just using the boiler plate config for the LD2420 from the ESPHome website but here it is anyway:

  name: office-presence
  friendly_name: Office_Presence

  board: esp01_1m

# Enable logging

# Enable Home Assistant API
    key: "redacted"

  password: "redacted"

  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: "Office-Presence Fallback Hotspot"
    password: "redacted"


# UART required to talk to LD2420 Presence sensor    
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 256000
  #baud_rate: 115200
  parity: NONE
  stop_bits: 1


  - platform: ld2420
      name: LD2420 Firmware

  - platform: ld2420
      name : Moving Distance

  - platform: ld2420
      name: Presence

  - platform: restart
    name: Restart ESPHome Node

  - platform: ld2420
      name: Operating Mode

  - platform: ld2420
      name: Detection Presence Timeout
      name: Detection Gate Minimum
      name: Detection Gate Maximum
      name: Select Gate to Set
      name: Set Still Threshold Value
      name: Set Move Threshold Value
  - platform: ld2420
      name: Apply Config
      name: Factory Reset
      name: Restart Module
      name: Undo Edits


Serial port

  1. Finding the Tx pin
    Since there appear to be two different pinnouts depending on the firmware running on the sensor itself I probed it under power with my oscilloscope for serial traffic. I found serial traffic on the OT2 pin so presumably I have a module with firmware >=1.5.3.

  2. Checking the baud rate
    There are two different baud rates in the yaml because I had seen other peoples configs with 115200 even through the manufacturer’s documentation says 256000 (see page 14).

So I tried both and if I use 115200 I get an error early in the install log saying that the HLK module failed to respond. If I do 256000 no such error.

  1. Checking I have Tx & Rx wired correctly
    I did flip Tx/Rx just to confirm I had them correctly.

  2. I did try hooking it up to tio on my linux dekstop via a UART to USB convert but got radio silence.

What does work

The sensor shows up in HA. I’m able to add it to a zone no problem and dump all of the parameters onto a card:

I do get info via the logs but…

The Strangeness

Nothin’ but bytes on the serial terminal

The logs all appear to be byte data? Or am I seeing Unicode?
For example:

[21:51:36]\x9d\xf0W!I@\xa8ޭ\x80ف\x9b\x9a\xb0\xabᗐ\xa1)64\xad\xeb\xc1\x97\xcer' \x9b\xb0Z\xfd\x93""T

If I change parameters on the HA widget I do see more traffic on the log.
Should I be seeing raw byte traffic?

The GUI will not set to anything but Operating Mode: Simple

No matter what I do, whenever I try to change the operating mode from Simple to anything else (Calibrate or Normal). It immediately flips back to Simple before I can hit the button to Apply the settings.

No useful data seems to be coming back

None of the data the sensor is suppose to report back seems to be making it into HA (everything shows as unknown). Given that I can’t get it into calibration mode this isn’t entirely surprising.

I’m not sure how to proceed further with debugging as I’m not actually sure what I should expect to see from the sensor in the first place.
If others have first hand experience with a working sensor I’d love to know how it should be behaving.

Right after making this post I swapped over to the second sensor module I have and on boot got a much clearer message on the logs that included this:

[22:10:23][W][uart.arduino_esp8266:143]:   You're using the same serial port for logging and the UART component. Please disable logging over the serial port by setting logger->baud_rate to 0.

I had forgotten how limited the ESP8266’s serial capabilities are.
I did do a quick test where I disabled the logger to see if I could get anything other than “Unknown” from the sensor in HA but no beans. Everything is still unknown.

I will have to try an ESP32 tomorrow since the second serial port on the 8266 is transmit only.

Alright, it seems the RPi 3 I’m running HA on just doesn’t have the juice to program an ESP32 via the ESPHome add-on. It seems like the supervisor is killing the process at the linking stage.

So I resorted to spinning up a docker container on my desktop PC and programming it that way. The ESP32 gets onto the main network (with the hostname I set in the yaml) however, I can’t seem to get HA to pair with it.

If I go Settinngs>Config>Devices>Add-device>ESPHome I get this:

The yaml I used to program the ESP32 does have the API line (it’s the same yaml as above just with ESP8266 swapped out for 32) along with a key but I am never presented with an opportunity to enter that key. I have double checked that the API is connect and both devices are definitely on the same network.

Am I missing something here? Is there a gotcha when it comes to programming with ESPHome from a computer that isn’t the HA node? When I flash the ESP I don’t see anything in the logs that would indicate an issues but HA doesn’t seem to find the device.