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).
Configuration
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:
esphome:
name: office-presence
friendly_name: Office_Presence
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "redacted"
ota:
password: "redacted"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Office-Presence Fallback Hotspot"
password: "redacted"
captive_portal:
# UART required to talk to LD2420 Presence sensor
uart:
tx_pin: GPIO1
rx_pin: GPIO3
baud_rate: 256000
#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
switch:
- platform: restart
name: Restart ESPHome Node
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
button:
- platform: ld2420
apply_config:
name: Apply Config
factory_reset:
name: Factory Reset
restart_module:
name: Restart Module
revert_config:
name: Undo Edits
Troubleshooting
Serial port
-
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. -
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.
-
Checking I have Tx & Rx wired correctly
I did flip Tx/Rx just to confirm I had them correctly. -
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
[21:51:36]\x89\xb2\xd3`Z\xfd\x93""*
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.
Edit:
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.