Gravity: Microwave Sensor (Motion Detection) (SEN0192)

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)

def callback(pin):
    global interrupt_flag

radar.irq(trigger=Pin.IRQ_FALLING, handler=callback)
while True:
    if interrupt_flag is 1:
        print("Motion detected")

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.

I pulled the code from a great article on GPIO interrupts

1 Like