GPIO 1 and 3 are almost always shared with usb, and have logging enabled to it, so they may give problems. If you do use them, when usb flashing, disconnect the wires, and add this to the yaml. OTA flashing is no problem afterward.
logger:
baud_rate: 0
My advice is to go with gpio16/17. Furthermore, the most made mistake is that when connecting, RX should go to TX and TX should go to RX. If your config does not work, try switching the wires.
Second often made mistake: GPIO numbers are not always the same as pin numbers. Check if you:
have the right documentation for the board. Also becasue there are many fake boards using popular names, but are very different
check which pin is which gpio
Third: measure voltage of where you connect 5v. Is it really 5v? Make sure it is properly powered.
ps. I made all of these mistakes. So if you only did one or two wrong, you are ahead of me
I have done all of your recommendations, one by one, just to double check if I missed them before but no luck.
Any other clue to keep looking for? I have also tried with 2 different brand ESP32 boards and als an ESP8266, with the same result. I tested also 3 LD2410C.
Do you think it could be the HA implementation? is a docker one and the ESPHome is installed in a separate container, ut as per my understanding ESPHome container is just to manage and facilitate configuration of ESP devices…
I have also tried modifying the settings like baud rate and distance resolution in HA and I can see them changed in the HLK App, so at least in one direction the communication is working.
ESPHome is not relevant other than for building and flashing the firmware. And if HA created the sensors, your HA api is working too. If you can communicate with the board and the app can see that through bluetooth, than at least the communication from the esp to the board is working. That leaves the communication the other way around as a possibility or a faulty sensor, as far as I can tell.
Did you check to see if you can get the out pin working? That does not rely on the UART but on the sensor alone. If you can get that to work, the sensor should work and the UART is still the problem. If you can’t then you either did that one wire wrong too or the sensor is dead.
You did not show the yaml for the uart you flashed with the picture, show that too just to be sure.
An adittional test I’ve done is, when I change a config in HA it is updated in the APP, however when I updated it in the app it is not updated in HA, so communication is just working from the ESP to the sensor and not the other way around.
One question, how can I try the out pin? how should I connect and configure the esp?
It is very strange that all 3 sensors I have tried are wrong, maybe they are as they all where bought together
As for the RX/TX settings: I never can figure if in the yaml you need to name rx/tx on the esp side or what you connected to it. I figured you specify the ESP side, not the connected board. So I very well may have it wrong, but at least it works for me. And I have them opposite of yours. tx =17 and rx =16. Which also probably means I have the wires the other way around at the board side. But I do wonder how that could have worked sending data to your board if it was wrong.
Changed the pins as suggested and include the binary sensor.
The Out pin is working.
When I send a change request for distance resolution from HA this is are the logs
[09:33:32][D][select:062]: 'distance resolution' - Setting
[09:33:32][D][select:115]: 'distance resolution' - Set selected option to: 0.2m
[09:33:32][D][select:015]: 'distance resolution': Sending state 0.2m (index 0)
[09:33:32][W][component:237]: Component api took a long time for an operation (119 ms).
[09:33:32][W][component:238]: Components should block for at most 30 ms.
[09:33:33][D][uart_debug:158]: >>> "\xFD\xFC\xFB\xFA\x04\x00\xFF\x00\x01\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x04\x00\xAA\x00\x01\x00\x04\x03\x02\x01"
[09:33:33][W][component:237]: Component ld2410 took a long time for an operation (101 ms).
[09:33:33][W][component:238]: Components should block for at most 30 ms.
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][uart_debug:158]: >>> "\xFD\xFC\xFB\xFA\x04\x00\xFF\x00\x01\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x02\x00\xA3\x00\x04\x03\x02\x01"
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state ON
[09:33:33][D][binary_sensor:036]: 'Presence pin': Sending state OFF
[09:33:34][W][component:237]: Component ld2410 took a long time for an operation (351 ms).
[09:33:34][W][component:238]: Components should block for at most 30 ms.
[09:33:34][D][uart_debug:158]: >>> "\xFD\xFC\xFB\xFA\x04\x00\xFF\x00\x01\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x02\x00\xA0\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x04\x00\xA5\x00\x01\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x02\x00\xAB\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x02\x00\xAE\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x02\x00a\x00\x04\x03\x02\x01\xFD\xFC\xFB\xFA\x02\x00\xFE\x00\x04\x03\x02\x01"
[09:33:34][D][binary_sensor:036]: 'Presence pin': Sending state ON
Your sensor has a voltage regulator. You need to power it at minimum 5V. And it regulates the voltage to 3.3V, so rx/tx voltages are compatible with Esp32.
ps. Don’t ever think that all other sensors work like that, most of them don’t have voltage regulator!
@Edwin_D the binary sensor works good, if I am not in the room it does not detect presence and if I am it does. In the app it behaves similarly, it goes on an off continuously