Interfacing PIR Motion Sensor with Raspberry Pi Pico

Hello,

In this article we are going to interface Raspberry Pi Pico with PIR sensor module and make Anti-Theft Alarm.

If someone enter in room or anywhere sensor is place, sensor will detect human and trigger alarm.

Here, we used buzzer as alarm. If PIR sensor module detect human or animal body it will give signal to Raspberry Pi Pico and pico will turn on the alarm.

Let’s make this.

If you are new to Raspberry Pi Pico and wants to get started then click here, it is all about getting started with Raspberry Pi Pico.

VIDEO

Required Components

List of required components is given below.

Raspberry Pi Pico

PIR Sensor Module

Buzzer

Jumper Wires

Bread Board

Schematic Diagram

Follow this schematic diagram and make connections.

Schematic Diagram
  • Connect Vcc of PIR sensor with 5V of Pico.
  • Connect Dout pin of PIR with GP28 pin of Pico.
  • Connect GND of PIR with GND of Pico.
  • Connect anode pin of buzzer with GP15 Pin of Pico.
  • Connect Cathode pin of buzzer with GND pin of Pico.

Coding

To write and upload program here i used Thonny IDE. You can download from here.

Here i write code in micropython.

from machine import Pin

PIR = Pin(28,Pin.IN)
Buz = Pin(15,Pin.OUT)

while True:
    if PIR.value() == 1:
        Buz.high()
        
    else:
        Buz.low()

Save this code in Raspberry Pi Pico and and name it main.py