shabaz123 / LD2410

GNU General Public License v3.0
6 stars 5 forks source link

TypeError: object of type 'NoneType' has no len() #2

Closed Mr-Mistoffelees closed 1 year ago

Mr-Mistoffelees commented 1 year ago

Thanks a lot for providing the code.

I've got some python skills but very limited electrical engineering skills so hopefully I don't bother you with some obvious mistake from my side.

I received my "SEN0557" [1] sensor which should be identical to the LD2410, regarding the fact that even the user manual [2] states "LD2410" on some pages.

Using a Raspi Pico [3], I connect the wires the following way:

VCC -> Red -> Raspi VBUS -> PinNr40 GND -> Black -> Raspi GND -> PinNr 38 UART RX -> Yellow -> RaspiTX -> GP8 -> PinNr11 UART TX -> Green -> RaspiRX -> GP9 -> PinNr12

...which perfectly fits to your Code from the file ld2410.py in line 23 ser = UART(1, baudrate = 256000, tx=Pin(8), rx=Pin(9), timeout = 1)

I just changed line 21 as proposed, due to the fact that I use a RP Pico: boardled = Pin(25, Pin.OUT)

Then I receive the following feedback from my Thonny IDE (same thing in PyCharm):

>>> %Run -c $EDITOR_CONTENT

MPY: soft reboot
Traceback (most recent call last):
  File "<stdin>", line 176, in <module>
  File "<stdin>", line 73, in read_firmware_version
  File "<stdin>", line 46, in print_bytes
TypeError: object of type 'NoneType' has no len()

I can change line 46 in your code to if data == None:

but then of course I receive the output

MPY: soft reboot
<no data>

The sonsor gets hot, but nothing else happends.

Pico is connected correctly. Testing it, using e.g. the on-board LED, works perfectly fine.

Any idea on how to fix this issue would be highly appreciated.

[1] https://wiki.dfrobot.com/SKU_SEN0557_24GHz_Human_Presence_Sensing_Module [2] https://dfimg.dfrobot.com/nobody/wiki/3b1c7de28d8343b114c3ab6057f817e2.pdf [3] https://blog.berrybase.de/wp-content/uploads/2021/01/Bildschirmfoto-2021-01-26-um-16.31.24.png

Mr-Mistoffelees commented 1 year ago

Issue could be solved after some tinkering, using the following code in line 23 (--> baudrate set to 57600): ser = UART(1, baudrate = 57600, tx=Pin(8), rx=Pin(9), timeout = 1)

For those who care, changing the main to

if __name__ == '__main__':
    run_forever()

made the program run forever. Of course. :)

So thanks for providing the code. Really helpful!