Hi @Adrian200392, @Trent5487676 and I just connected a unit to an oscilloscope and can confirm the following:
- the device is 5V powered and outputs a 5V signal. To use with a Pico you will need to shift-down the logic level eg. with a voltage divider
- the signal is active-low: motion is indicated by a 5V to 0V transition.
- There is very little hold time in the signal (we saw as short as 60ms) so you should probably use interrupt-driven code. This agrees with DF Robot’s example code for arduino which uses interrupts. @Jacob’s polling code with 100ms loop time is too slow.
The following code should print when detecting a falling edge (motion).
The print occurs outside the callback so that the callback remains as brief as possible.
from machine import Pin
radar = Pin(2, Pin.IN)
interrupt_flag=0
def callback(pin):
global interrupt_flag
interrupt_flag=1
radar.irq(trigger=Pin.IRQ_FALLING, handler=callback)
while True:
if interrupt_flag is 1:
print("Motion detected")
interrupt_flag=0
Hopefully the change to the circuit and code helps. We did observe that many edges are generated when motion is detected - probably because movements are being acquired as separate events or perhaps this is even to help with calculating some velocity.
Resources
I pulled the code from a great article on GPIO interrupts