Skip to content
Circuits Playground
Menu
BeginnerRule-checked

Raspberry Pi Pico PIR Motion Alarm

Detect movement with an HC-SR501 PIR sensor and flash an LED and sound a buzzer on a Raspberry Pi Pico.

Board
Raspberry Pi Pico
Build time
30 min
Status
Rule-checked
Last revised

Passed the automatic wiring rules. Not yet physically built and tested.

Quick answer

To build the Raspberry Pi Pico PIR Motion Alarm you need a Raspberry Pi Pico and HC-SR501 PIR Motion Sensor, Resistor, LED (5 mm), Active Buzzer Module, 9× Jumper wires + breadboard. It is a beginner project with 9 connections, takes about 30 min and costs roughly ₹530–₹800 in parts.

The HC-SR501 needs at least 4.5 V to run, but its output is 3.3 V, perfect for the Pico. Power it from VBUS (USB 5 V) and read its output on GP15.

Raspberry Pi PicoGP0GP1GNDGP2GP3GP4GP5GNDGP6GP7GP8GP9GNDGP10GP11GP12GP13GNDGP14GP15VBUSVSYSGND3V3_EN3V3(OUT)ADC_VREFGP28AGNDGP27GP26RUNGP22GNDGP21GP20GP19GP18GNDGP17GP16PIR sensorVCCOUTGNDR1330Ω12Alarm LEDredA (+)K (−)BuzzerVCCI/OGND
Circuit diagram for Raspberry Pi Pico PIR Motion Alarm (revision 2026-11-12). Wire colours: red = power, grey = ground, blue = signal, purple = I2C, green = analog, orange = switched load.

Download

Parts list

QtyPartNotesBuy
1Raspberry Pi PicoRP2040 microcontroller board with 26 GPIO, 3 ADC inputs and 3.3 V logic.Amazon.inRobu.in
1HC-SR501 PIR Motion SensorPassive infrared motion detector with adjustable sensitivity and delay; 3.3 V digital output.Amazon.inRobu.in
1Resistor, 330ΩFixed through-hole resistor. Set its value in the properties panel.
1LED (5 mm), redStandard through-hole LED. Always use a series resistor.Amazon.inRobu.in
1Active Buzzer ModuleBuzzer module with built-in oscillator and transistor driver; sounds when the input is driven.Amazon.inRobu.in
9Jumper wires + breadboardMale/female jumpers as required by the modules' headers.Amazon.inRobu.in

Estimated cost: ₹530–₹800 including a breadboard and jumper wires (typical Indian online prices, 2026-11). Some links may be affiliate links, they cost you nothing extra and help keep this site free.

Pin-to-pin wiring

FromPinToPinType
Alarm LEDK (−)Raspberry Pi PicoGNDground
BuzzerVCCRaspberry Pi Pico3V3(OUT)power
BuzzerI/ORaspberry Pi PicoGP13signal
BuzzerGNDRaspberry Pi PicoGNDground
PIR sensorVCCRaspberry Pi PicoVBUSpower
PIR sensorOUTRaspberry Pi PicoGP15signal
PIR sensorGNDRaspberry Pi PicoGNDground
R11Raspberry Pi PicoGP14signal
R12Alarm LEDA (+)signal

Step-by-step build

  1. 1

    Power the PIR from VBUS

    PIR VCC → VBUS (pin 40), GND → any GND, OUT → GP15.

  2. 2

    Add the LED

    GP14 → 330 Ω resistor → LED long leg (anode). LED short leg (cathode) → GND.

  3. 3

    Add the buzzer

    Buzzer VCC → 3V3(OUT), I/O → GP13, GND → GND.

  4. 4

    Tune the PIR

    Turn both PIR potentiometers fully anticlockwise (lowest sensitivity, shortest delay) and adjust from there.

AI code-generation prompt

Paste this into Gemini, ChatGPT, Claude or another coding assistant. It includes the exact pin map. Treat the generated code as untested until you have run it.

You are an experienced embedded firmware engineer. Write complete, compilable firmware for the project below.

## Project
Title: Pico PIR Motion Alarm
Description: PIR motion detection with LED and buzzer alert.
Board: Raspberry Pi Pico, 3.3 V logic
Development environment: MicroPython
Connectivity: none (runs offline)

## Required behaviour
Ignore the PIR for the first 60 seconds after boot (warm-up) while blinking the LED slowly. After that, when motion is detected, flash the LED quickly and beep three short beeps. Do not alarm again for 10 seconds after an alarm.

## Components
- 1 × Raspberry Pi Pico
- 1 × HC-SR501 PIR Motion Sensor
- 1 × Resistor (330Ω)
- 1 × LED (5 mm) (red)
- 1 × Active Buzzer Module

## Exact pin map (do not change these pins)
- PIR sensor VCC → VBUS
- PIR sensor OUT → GP15
- PIR sensor GND → GND
- R1 1 → GP14
- Alarm LED K (−) → GND
- Buzzer VCC → 3V3 (3V3(OUT))
- Buzzer I/O → GP13
- Buzzer GND → GND

## Assumptions
- The Pico is powered from USB so VBUS supplies 5 V.
- PIR jumper set to repeat-trigger (H) mode.

## Requirements for the code
- Use only the pins listed above, defined once as named constants at the top.
- Non-blocking structure using millis() (no long delay() calls in loop()).
- Put all outputs (relays, motors, buzzers) in a safe OFF state in setup() before anything else.
- Print readable debug output to Serial at 115200 baud.
- Handle sensor read failures (e.g. NaN, timeouts, missing I2C device) without crashing, and report them.
- Put thresholds and calibration values in clearly named constants with comments.

## What to return
1. The complete source file(s), ready to compile in MicroPython.
2. The exact libraries (with the library manager names) and board package to install.
3. A short explanation of how the code works and how to calibrate it.
4. A testing checklist I can follow step by step.

Do not invent pins, libraries or functions that do not exist. If something in this spec is ambiguous or unsafe, say so before writing code.

Troubleshooting & common mistakes

Alarm triggers constantly
Wait the full 60 s warm-up, reduce sensitivity and keep the sensor away from heaters and windows.
LED doesn't light
Check LED orientation: the long leg goes to the resistor, the flat side of the rim to GND.

Safety, assumptions & checks

Safety notes

  • Low-voltage USB project; no special hazards.
  • GPIO pins are 3.3 V only and are not 5 V tolerant.

Assumptions

  • The Pico is powered from USB so VBUS supplies 5 V.
  • PIR jumper set to repeat-trigger (H) mode.

Automatic wiring check (rules-2026.11.1)

✔ No problems found by the wiring rules.

The checker finds known wiring mistakes. It is not a simulator and cannot guarantee the circuit is safe or will work.

Viva and interview questions

Questions examiners commonly ask about the parts in this circuit, with short answers.

  1. Q1. What is the RP2040?

    A dual-core ARM Cortex-M0+ microcontroller designed by Raspberry Pi, used on the Pico.

  2. Q2. What is the difference between VBUS and VSYS on the Pico?

    VBUS is the 5 V from USB. VSYS is the main system input (1.8–5.5 V) that feeds the on-board regulator.

  3. Q3. What does a PIR sensor detect?

    Changes in infrared radiation, such as a warm body moving across its field of view. It cannot detect a still person.

  4. Q4. What do the two potentiometers on the HC-SR501 adjust?

    Sensitivity (range) and the time the output stays HIGH after motion is detected.

  5. Q5. Why does an LED need a series resistor?

    To limit current. Without it the LED draws too much current and burns out (and can damage the GPIO).

  6. Q6. How do you calculate an LED resistor?

    R = (supply voltage − LED forward voltage) / current. For 5 V, a 2 V red LED and 15 mA: (5 − 2) / 0.015 ≈ 200 Ω → use 220 Ω.

  7. Q7. What is the difference between an active and a passive buzzer?

    An active buzzer has a built-in oscillator and beeps with DC. A passive buzzer needs a PWM tone signal.

Frequently asked questions

What components do I need for the Raspberry Pi Pico PIR Motion Alarm?

You need a Raspberry Pi Pico and HC-SR501 PIR Motion Sensor, Resistor, LED (5 mm), Active Buzzer Module, 9× Jumper wires + breadboard, plus a breadboard, jumper wires and a USB cable.

How much does the Raspberry Pi Pico PIR Motion Alarm cost to build in India?

About ₹530–₹800 for new parts from Indian online stores (estimate, 2026-11). Reusing a board you already own makes it much cheaper.

How long does it take to build?

About 30 min for a beginner maker, including wiring and uploading code.

Is this project suitable as a college or school project?

Yes. It is a beginner project that suits school science exhibitions, diploma practicals and first-year engineering mini projects. Extend it with a web dashboard or data logging for a bigger project.

What should I do if: Alarm triggers constantly?

Wait the full 60 s warm-up, reduce sensitivity and keep the sensor away from heaters and windows.

What should I do if: LED doesn't light?

Check LED orientation: the long leg goes to the resistor, the flat side of the rim to GND.

Report a mistake in this project

Related