Ticker

6/recent/ticker-posts

Header Ads Widget

PIR Motion Sensor with Raspberry Pi Pico RP2040

Hello guys, in this blog, I will discuss HC-SR501 Pir Motion Sensor, its interfacing with Raspberry Pi Pico, and its programming in Micropython using Thonny ide.

The HC-SR501 Motion sensor is quite popular among the DIY community due to its low power and low cost, ease to use, and wide detection range. 

HC-SR501 PIR Motion sensor has 3 output pins VCC, GND, and OUT, It has an onboard voltage regulator to drive it between voltage range 4.5 to 12 Volts. In the case of this blog, I am going to use 5V from Pico 5v Pin.

Components Required

  • Raspberry Pi Pico x 1
  • HC-SR501 PIR Sensor x 1
  • USB Cable for programming x 1
  • Breadboard (optional)
  • Jumper cables

Circuit Diagram

Wiring of this setup is quite easy and simple, Connect VCC of Pir Sensor to VBUS (5V) Pin of Raspberry Pi Pico, GND to GND terminal of PICO, and OUT pin to GP16 of Raspberry Pi Pico. This Connection diagram of HC-SR501 PIR  Motion Sensor with Raspberry Pi Pico will guide you to connect things easily in no time. 


Source Code:

from machine import Pin
import utime

pir_sensor = Pin(16, Pin.IN)
utime.sleep(2)

while True:
   if pir_sensor.value() == 1:
       print("Motion Detected")
       utime.sleep(3)
   else:
       print("No Motion")
       utime.sleep(1)
utime.sleep(0.1)

Post a Comment

0 Comments