I’ve been trying to get a LD2420 mmWave presence module working with ESPHome and an ESP32 devboard I have kicking around.
In the process I discovered that the RPi3 I am running my home assistant instance on just doesn’t have the juice to program the ESP32 from the ESPHome add-on. Even with all other add-ons disabled it (and compile process limit = 1
) appears to get killed by the Supervisor at linking.
I’ve tried to side-step this issue (and migrating my instance) for now by programming the ESP32 via a docker container running ESPHome on my desktop.
This does succeed (spoilers: it “succeeds” because the ESP is booting into safemode) in programming the ESP32 which appears on my network buuuut HomeAssistant never autodiscovers the device nor am I able to add it manually:
Settings>Devices>Add Device>ESPHome
Yields this:
The yaml I used to program the ESP32 is the follwing (which defs has the api line):
esphome:
name: office-presence
friendly_name: Office_Presence
esp32:
board: esp32dev
# Enable logging - Uses UART0
logger:
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:
tx_pin: GPIO17
rx_pin: GPIO16
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
Now there is the odd quirk that the docker container that I used to program the ESP32 isn’t able to see the ESP as “online” (because safe mode):
This is the docker compose file I am using:
version: '3'
services:
esphome:
container_name: esphome
image: ghcr.io/esphome/esphome
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
volumes:
- ~/bin/ESPHome/ESPHome/config:/config
- /etc/localtime:/etc/localtime:ro
restart: always
privileged: true
network_mode: host
environment:
- USERNAME=test
- PASSWORD=redacted
However, as mentioned above the ESP does make it onto the network and here is the log of it flashing the ESP (Please see second post in thread due to post character limit).
So something is going pear-shaped and I’m not quite sure what. I am programming via the serial port that appears at /dev/ttyUSB1
because if I try to program via /dev/ttyUSB0
the device doesn’t respond.
If I remove everything from ld2420
downwards the ESP comes “online” in the container and the HA ESPHome add-on finds the device automagically. So it’s something wrong with my ld2420 configuration which happens to be the boilerplate from the ESPHome page for the device.
Nothing is wrong with the yaml (so far as I can tell). At least if I run validate I get INFO Configuration is valid!
.
I have tried two different ld2420 modules and both combinations of Tx/Rx (just incase I got it backwards even after probing the pins with my scope for serial traffic).
When I had gotten Tx/Rx backwards on an attempt with an ESP8266 I got errors in the log about the ld2420 not responding rather than a bootloop. That might be what’s happening here
I’m not sure what else to try at this stage.