Header banner
Revain logoHome Page
Alexander Scharon photo
1 Level
1336 Review
90 Karma

Review on πŸ” HiLetgo 3pcs HC-SR501 PIR Infrared Sensor Human Body Motion Module for Arduino Raspberry Pi by Alexander Scharon

Revainrating 5 out of 5

Works well with Pi Pico

I had fun building a little circuit that would beep, blink an LED and write on an OLED display when anything moves in space. It comes with a nice data sheet that simplifies wiring. Sensor: red wire to Vbus on pico, yellow wire to GP28, gray wire to GND on pico, LED on Gnd Buzzer: GP14 to buzzer on Gnd Micropython: import machineimport utimefrom ssd1306 import SSD1306_I2Csensor_pir = machine.Pin(28, machine.Pin. IN, machine.Pin.PULL_DOWN)sda=machine.Pin(20)scl=machine.Pin(21 )i2c=machine.I2C(0, sda=sda, scl=scl, freq=400000)led = machine.Pin( 3, machine.Pin.OUT)oled = SSD1306_I2C(128, 32, i2c)buzzer = machine.Pin (14, machine.Pin.OUT)def pir_handler(pin): utime.sleep_ms(100) if pin.value() : print (i2c.scan()) oled.text('Motion detected!', 0, 0) oled.show() utime.sleep_ms(1000) for i in range (20): led.toggle() buzzer.toggle () utime.sleep_ms(100) utime.sleep_ms(100) oled.fill(0) oled.show ()sensor_pir.irq(trigger=machine.Pin.IRQ_RISING, handler=pir_handler)

Pros
  • Great price
Cons
  • Big and bulky