I have an ld2420 (Firmware ver 1.5.9) wired to a d1_mini and have put the GPIO out pin to D0.
I am aiming to take the output from the GPIO pin (HIGH for Presence, LOW for ABSENCE) and publish it to my broker using MQTT. I believe that the GPIO pin needs to be enabled and here I am stuck.
Below is the relevant sections of the LD2420 code that compiles but the GPIO pin doesn’t change from LOW to HIGH when presence is detected.
If I look at the log and physically bring the pin from LOW to HIGH I can see that change being reported in the log but it immediately reverts to LOW when not physically pulled HIGH.
Any Ideas?
uart:
id: ld2420_uart
tx_pin: D5
rx_pin: D6
baud_rate: 115200
parity: NONE
stop_bits: 1
################################################################################
# Scripts to Send Hex Strings
################################################################################
script:
- id: send_hex_string_1
then:
- uart.write: [0xFF, 0x55, 0x07, 0x01, 0x05, 0x00, 0x01, 0x00, 0x64] #initialize gpio D0
- id: send_hex_string_2
then:
- uart.write: [0xFF, 0x55, 0x08, 0x01, 0x03, 0x00, 0x1F, 0x40, 0xB8] #set 8 m detection distance
# The LD2420 has 16 sense gates 0-15 and each gate detects 0.7 meters 15th gate = 9m
ld2420:
text_sensor:
- platform: ld2420
fw_version:
name: LD2420 Firmware
binary_sensor:
- platform: gpio
pin:
number: D0
mode: INPUT_PULLDOWN
name: "D0 State"
id: d0_state
on_press:
then:
- logger.log: "D0 State is ON"
- mqtt.publish:
topic: "${mqtt_prefix}/KITCHEN/HMMD_4/SWITCH/MAIN/SENSOR"
payload: "ON"
on_release:
then:
- logger.log: "D0 State is OFF"
- mqtt.publish:
topic: "${mqtt_prefix}/KITCHEN/HMMD_4/SWITCH/MAIN/SENSOR"
payload: "OFF"
select:
- platform: ld2420
operating_mode:
name: Operating Mode
number:
- platform: ld2420
presence_timeout:
name: Detection Presence Timeout # How long before the sensor is set to cleared after last detection
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 # applies configuration (used to set calibrated values)
factory_reset:
name: Factory Reset # As the name says
restart_module:
name: Restart Module # as the name says
revert_config:
name: Abort Edits
################################################################################
# Publish D7 State to MQTT Every 10 Seconds
################################################################################
interval:
- interval: 10s
then:
- mqtt.publish:
topic: "${mqtt_prefix}/KITCHEN/HMMD_4/SWITCH/MAIN/SENSOR"
payload: !lambda 'return id(d0_state).state ? "ON" : "OFF";'ype or paste code here