Teckinfor
(Sénéchal Julien)
September 5, 2024, 11:52am
1
Hello,
I’m new to ESPHome so I apologize in advance if I make any rookie mistakes.
I’m trying to make a presence detector with an S2 Mini and an LD2410C module. I am sure of my connections and my code can be found here :
esphome:
name: detecteur-presence
friendly_name: Detecteur de présence
esp32:
board: lolin_s2_mini
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "tNGr6Axv3U2JuJBvOQVLSAoJyNuq3ePpgpqb6LoFXh4="
ota:
- platform: esphome
password: "740f8c67140f070f7c6df31e9f615ec0"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Detecteur-Milimetrique"
password: "23xVtBnfrnML"
captive_portal:
uart:
- id: uard1
tx_pin: 33
rx_pin: 18
baud_rate: 9600
ld2410:
- id: "ld_uart1"
throttle: 1500ms
uart_id: uard1
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
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
web_server:
text_sensor:
- platform: ld2410
version:
name: "firmware version"
mac_address:
name: "mac address"
With this same code, if I have the LD2410C module de-soldered, I can access the web page and even remount it in HomeAssistant. But since I soldered it, this is no longer possible.
However, I know that the module is working properly, as I’ve been able to connect to it via Bluetooth and I’m receiving information.
Could you help me understand what’s going on?
Many thanks in advance
alfwro13
(Andre W.)
September 5, 2024, 12:01pm
2
Check the documentation - LD2410 Sensor — ESPHome
baud_rate should be 256000 and not 9600
Teckinfor
(Sénéchal Julien)
September 5, 2024, 1:08pm
3
Hello thank you for your suggestion
I tried but it stills the same.
And as my s2mini is connected to my windows, i ear it resetting various time.
Here you have the new code :
esphome:
name: detecteur-presence
friendly_name: Detecteur de présence
esp32:
board: lolin_s2_mini
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "tNGr6Axv3U2JuJBvOQVLSAoJyNuq3ePpgpqb6LoFXh4="
ota:
- platform: esphome
password: "740f8c67140f070f7c6df31e9f615ec0"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Detecteur-Milimetrique"
password: "23xVtBnfrnML"
captive_portal:
uart:
- id: uard1
tx_pin: 33
rx_pin: 18
baud_rate: 256000
parity: NONE
stop_bits: 1
ld2410:
- id: "ld_uart1"
throttle: 1500ms
uart_id: uard1
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
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
web_server:
text_sensor:
- platform: ld2410
version:
name: "firmware version"
mac_address:
name: "mac address"
koying
(Chris B)
September 5, 2024, 1:57pm
4
That means that VCC and GND are properly wired. Not more, not less.
What do you see in the esphome logging?
Did you cross TX and RX?
Teckinfor
(Sénéchal Julien)
September 5, 2024, 2:34pm
5
If i refer to the Wemos documentation, the TX and RX are correctly configured :
And the module is this one: HLK-LD2410C capteur de présence RF 24GHz – Esp32Lab.com
And during logging nothing… But what i don’t understand is that my ESP was working before adding the LD2140c module
I’m trying to learn but it’s not that simple haha
koying
(Chris B)
September 5, 2024, 2:40pm
6
I meant the TX of the ESP should go to the RX of the LD240, and vice-versa.
Also, I think the hardware uart runs on pin 37/39 on that board.
I guess it should work on software uart as well…
Teckinfor
(Sénéchal Julien)
September 5, 2024, 2:47pm
7
I’ve seen a lot of tutorials that set up their LD2410c like me and worked.
I’m convinced that’s not where the problem lies.
Teckinfor
(Sénéchal Julien)
September 5, 2024, 8:42pm
8
It seems that the ESP stopped founding my network but i don’t understand why
Teckinfor
(Sénéchal Julien)
September 5, 2024, 8:59pm
9
Adding a static IP resolved the problem, don’t understand why…
Hope it can help someone else
But now i still not having information from the LD2410C
nickrout
(Nick Rout)
September 6, 2024, 6:14am
10
Is there a reason for using the Arduino framework? If it’s recommended for the s2. ESP32 Platform — ESPHome
Teckinfor
(Sénéchal Julien)
September 6, 2024, 7:33am
11
To be honest, is what i saw in a tutorial but let’s try
I’m not sure about the difference between both but i’ll attempt
Teckinfor
(Sénéchal Julien)
September 6, 2024, 8:00am
12
Same as before :
Here is the yaml file :
esphome:
name: detecteur-presence
friendly_name: Detecteur de présence
esp32:
board: lolin_s2_mini
framework:
type: esp-idf
version: recommended
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "tNGr6Axv3U2JuJBvOQVLSAoJyNuq3ePpgpqb6LoFXh4="
ota:
- platform: esphome
password: "740f8c67140f070f7c6df31e9f615ec0"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
output_power: 8.5
manual_ip:
static_ip: 192.168.129.206
gateway: 192.168.128.1
subnet: 255.255.0.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Detecteur-Milimetrique"
password: "23xVtBnfrnML"
captive_portal:
uart:
- id: uard1
tx_pin: 33
rx_pin: 18
baud_rate: 256000
parity: NONE
stop_bits: 1
ld2410:
- id: "ld_uart1"
throttle: 1500ms
uart_id: uard1
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
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
web_server:
text_sensor:
- platform: ld2410
version:
name: "firmware version"
mac_address:
name: "mac address"
koying
(Chris B)
September 6, 2024, 9:16am
13
The esphome log might be useful
Teckinfor
(Sénéchal Julien)
September 6, 2024, 11:31am
14
There is nothing significant :
INFO ESPHome 2024.8.3
INFO Reading configuration /config/esphome/detecteur-de-presence.yaml...
INFO Starting log output from 192.168.129.206 using esphome API
INFO Successfully connected to detecteur-presence @ 192.168.129.206 in 0.077s
INFO Successful handshake with detecteur-presence @ 192.168.129.206 in 0.110s
[13:30:05][I][app:100]: ESPHome version 2024.8.3 compiled on Sep 6 2024, 09:56:06
[13:30:05][C][wifi:600]: WiFi:
[13:30:05][C][wifi:428]: Local MAC: 84:F7:03:DD:BA:3E
[13:30:05][C][wifi:433]: SSID: [redacted]
[13:30:05][C][wifi:436]: IP Address: 192.168.129.206
[13:30:05][C][wifi:440]: BSSID: [redacted]
[13:30:05][C][wifi:441]: Hostname: 'detecteur-presence'
[13:30:05][C][wifi:443]: Signal strength: -64 dB ▂▄▆█
[13:30:05][C][wifi:447]: Channel: 11
[13:30:05][C][wifi:448]: Subnet: 255.255.0.0
[13:30:05][C][wifi:449]: Gateway: 192.168.128.1
[13:30:05][C][wifi:450]: DNS1: 0.0.0.0
[13:30:05][C][wifi:451]: DNS2: 0.0.0.0
[13:30:05][C][logger:185]: Logger:
[13:30:05][C][logger:186]: Level: DEBUG
[13:30:05][C][logger:188]: Log Baud Rate: 115200
[13:30:05][C][logger:189]: Hardware UART: USB_CDC
[13:30:05][C][uart.idf:161]: RX Pin: GPIO18
[13:30:05][C][uart.idf:163]: RX Buffer Size: 256
[13:30:05][C][uart.idf:165]: Baud Rate: 256000 baud
[13:30:05][C][uart.idf:166]: Data Bits: 8
[13:30:05][C][uart.idf:167]: Parity: NONE
[13:30:05][C][uart.idf:168]: Stop bits: 1
[13:30:05][C][ld2410:022]: LD2410:
[13:30:05][C][ld2410:024]: TargetBinarySensor 'Presence'
[13:30:05][C][ld2410:024]: Device Class: 'occupancy'
[13:30:05][C][ld2410:025]: MovingTargetBinarySensor 'Moving Target'
[13:30:05][C][ld2410:025]: Device Class: 'motion'
[13:30:05][C][ld2410:026]: StillTargetBinarySensor 'Still Target'
[13:30:05][C][ld2410:026]: Device Class: 'occupancy'
[13:30:05][C][ld2410:027]: OutPinPresenceStatusBinarySensor 'out pin presence status'
[13:30:05][C][ld2410:027]: Device Class: 'presence'
[13:30:05][C][ld2410:039]: LightSensor 'light'
[13:30:05][C][ld2410:039]: Device Class: 'illuminance'
[13:30:05][C][ld2410:039]: State Class: ''
[13:30:05][C][ld2410:039]: Unit of Measurement: ''
[13:30:05][C][ld2410:039]: Accuracy Decimals: 0
[13:30:05][C][ld2410:039]: Icon: 'mdi:lightbulb'
[13:30:05][C][ld2410:040]: MovingTargetDistanceSensor 'Moving Distance'
[13:30:05][C][ld2410:040]: Device Class: 'distance'
[13:30:05][C][ld2410:040]: State Class: ''
[13:30:05][C][ld2410:040]: Unit of Measurement: 'cm'
[13:30:05][C][ld2410:040]: Accuracy Decimals: 0
[13:30:05][C][ld2410:040]: Icon: 'mdi:signal-distance-variant'
[13:30:05][C][ld2410:041]: StillTargetDistanceSensor 'Still Distance'
[13:30:05][C][ld2410:041]: Device Class: 'distance'
[13:30:05][C][ld2410:041]: State Class: ''
[13:30:05][C][ld2410:041]: Unit of Measurement: 'cm'
[13:30:05][C][ld2410:041]: Accuracy Decimals: 0
[13:30:05][C][ld2410:041]: Icon: 'mdi:signal-distance-variant'
[13:30:05][C][ld2410:042]: MovingTargetEnergySensor 'Move Energy'
[13:30:05][C][ld2410:042]: State Class: ''
[13:30:05][C][ld2410:042]: Unit of Measurement: '%'
[13:30:05][C][ld2410:042]: Accuracy Decimals: 0
[13:30:05][C][ld2410:042]: Icon: 'mdi:motion-sensor'
[13:30:05][C][ld2410:043]: StillTargetEnergySensor 'Still Energy'
[13:30:05][C][ld2410:043]: State Class: ''
[13:30:05][C][ld2410:043]: Unit of Measurement: '%'
[13:30:05][C][ld2410:043]: Accuracy Decimals: 0
[13:30:05][C][ld2410:043]: Icon: 'mdi:flash'
[13:30:05][C][ld2410:044]: DetectionDistanceSensor 'Detection Distance'
[13:30:05][C][ld2410:044]: Device Class: 'distance'
[13:30:05][C][ld2410:044]: State Class: ''
[13:30:05][C][ld2410:044]: Unit of Measurement: 'cm'
[13:30:05][C][ld2410:044]: Accuracy Decimals: 0
[13:30:05][C][ld2410:044]: Icon: 'mdi:signal-distance-variant'
[13:30:05][C][ld2410:053]: VersionTextSensor 'firmware version'
[13:30:05][C][ld2410:053]: Icon: 'mdi:chip'
[13:30:05][C][ld2410:054]: MacTextSensor 'mac address'
[13:30:05][C][ld2410:054]: Icon: 'mdi:bluetooth'
[13:30:05][C][ld2410:063]: LightThresholdNumber 'light threshold'
[13:30:05][C][ld2410:063]: Icon: 'mdi:lightbulb'
[13:30:05][C][ld2410:063]: Device Class: 'illuminance'
[13:30:05][C][ld2410:064]: MaxStillDistanceGateNumber 'max still distance gate'
[13:30:05][C][ld2410:064]: Icon: 'mdi:motion-sensor'
[13:30:05][C][ld2410:064]: Device Class: 'distance'
[13:30:05][C][ld2410:065]: MaxMoveDistanceGateNumber 'max move distance gate'
[13:30:05][C][ld2410:065]: Icon: 'mdi:motion-sensor'
[13:30:05][C][ld2410:065]: Device Class: 'distance'
[13:30:05][C][ld2410:066]: TimeoutNumber 'timeout'
[13:30:05][C][ld2410:066]: Icon: 'mdi:timelapse'
[13:30:05][C][ld2410:066]: Unit of Measurement: 's'
[13:30:05][C][ld2410:075]: Throttle_ : 1500ms
[13:30:05][C][ld2410:076]: MAC Address :
[13:30:05][C][ld2410:077]: Firmware Version :
[13:30:05][C][captive_portal:088]: Captive Portal:
[13:30:06][C][web_server:145]: Web Server:
[13:30:06][C][web_server:146]: Address: 192.168.129.206:80
[13:30:06][C][mdns:116]: mDNS:
[13:30:06][C][mdns:117]: Hostname: detecteur-presence
[13:30:06][C][esphome.ota:073]: Over-The-Air updates:
[13:30:06][C][esphome.ota:074]: Address: 192.168.129.206:3232
[13:30:06][C][esphome.ota:075]: Version: 2
[13:30:06][C][esphome.ota:078]: Password configured
[13:30:06][C][safe_mode:018]: Safe Mode:
[13:30:06][C][safe_mode:020]: Boot considered successful after 60 seconds
[13:30:06][C][safe_mode:021]: Invoke after 10 boot attempts
[13:30:06][C][safe_mode:023]: Remain in safe mode for 300 seconds
[13:30:06][C][api:139]: API Server:
[13:30:06][C][api:140]: Address: 192.168.129.206:6053
[13:30:06][C][api:142]: Using noise encryption: YES
koying
(Chris B)
September 6, 2024, 12:49pm
15
Not sure if it’s needed considering you are using a software uart, but I have to do
logger:
baud_rate: 0
to disable serial logging in order to use the uart.
That doesn’t prevent network logging.
If you are soldering the LD2410 pins directly to the ESP, your TX and RX are reversed.
uart:
id: ld2410_uart
tx_pin: GPIO18
rx_pin: GPIO33
baud_rate: 256000
parity: NONE
stop_bits: 1
2 Likes
Teckinfor
(Sénéchal Julien)
September 7, 2024, 6:26pm
17
You are a genius
But why ? I don’t understand why do we have to switch them
The reason, as explained earlier, is that tx on the LD2410c should be connected to rx on the ESP and rx to tx.
1 Like
nickrout
(Nick Rout)
September 7, 2024, 9:59pm
19
When device A is transmitting device B is receiving. Simple when you think it through.
1 Like