Raspberry Pi Pico

Raspberry Pi Pico PIR Sensor Interfacing and Programming

Raspberry Pi Pico PIR Sensor:

 

Raspberry Pi Pico PIR Sensor Interfacing and Programming- In this article, I will show you how to use a PIR sensor and a 5V buzzer with the Raspberry Pi Pico. We will be making a small security system.

Previous Articles:

Raspberry Pi Pico Vs Arduino.

Raspberry Pi Pico Pinout & Specs

Raspberry Pi Pico MicroPython and Thonny IDE Installation.

Raspberry Pi Pico Led examples.

Raspberry Pi Pico Digital Input.

Raspberry Pi Pico Oled Display Module SSD1306

Raspberry Pi Pico ADC Analog Sensor

Raspberry Pi Pico Temperature Sensor.

Raspberry Pi Pico Ultrasonic Sensor.

Raspberry Pi Pico LDR Sensor, Day & Night Detection.


Amazon Links:

Raspberry Pi Pico

PIR Sensor

5V Buzzer

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

 

Raspberry Pi Pico

The PIR Sensor triggers the Pico Board each time motion is detected and then the Raspberry Pi Pico board turns on the Buzzer. Let’s go ahead and take a look at the circuit diagram.  



Raspberry Pi Pico PIR Sensor Circuit Diagram:

Raspberry Pi Pico

The PIR Motion Sensor Red and Black wires are connected with the Raspberry Pi Pico board 3.3V and GND pins. While the signal wire of the PIR sensor is connected with the GP14 of the Pico board. This is a 5V buzzer and it can’t be directly controlled using the Pico board; so, that’s why I am using this driver circuit to turn ON and OFF this buzzer. The base of the transistor is connected with GP28 pin of the Raspberry Pi Pico Board. So, that’s all about the connections.


Raspberry Pi Pico PIR Motion Sensor Programming:

from machine import Pin

import time




buzzer = Pin(28, Pin.OUT)

PirSensor = Pin(14, Pin.IN, Pin.PULL_DOWN)




while True:

    if PirSensor.value():

        buzzer.value(1)

        time.sleep(3)

        buzzer.value(0)

        time.sleep(5)

    else:

        buzzer.value(0)

I defined buzzer as the output and PIR Sensor as the Input. Buzzer is connected to GP28 and PIR Sensor is connected to GP14. I am going to call these pins the buzzer and PirSensor.

Inside the while loop, we check if the PIR Motion sensor has detected any motion and then accordingly turn ON and turn OFF the buzzer.  So, that’s all about the code.

I uploaded the code and it was working perfectly. For the practical demonstration watch video given below.

Next article, Raspberry Pi Pico Digital LDR Sensor for Day and Night detection.

Watch Video:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button