Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsA real alarm needs an arming delay, or it goes off as you walk away from it. The red LED blinks slowly for 30 seconds while you leave, then the PIR keeps watch. Any movement flashes the LED and beeps the buzzer for 20 seconds, after which it re-arms by itself.
Tick anything you already have and the total updates.
Passive infrared sensor that detects the body heat of moving people or animals up to about 7 m away.
Active buzzer with a built-in oscillator: apply power and it beeps at about 2.3 kHz.
Follow the colours: red is power, dark grey is ground, blue is a signal.
main.py# Pico PIR intruder alarm with an arming delay (MicroPython)
from machine import Pin
import time
pir = Pin(15, Pin.IN)
buzzer = Pin(14, Pin.OUT)
led = Pin(13, Pin.OUT)
ARM_DELAY_S = 30 # time to leave the room after power-up
ALARM_S = 20 # how long the alarm sounds
print("Arming in", ARM_DELAY_S, "seconds")
for i in range(ARM_DELAY_S):
led.toggle(); time.sleep(1) # slow blink while arming
led.value(0)
print("Armed")
while True:
if pir.value() == 1:
print("Movement!")
end = time.ticks_add(time.ticks_ms(), ALARM_S * 1000)
while time.ticks_diff(end, time.ticks_ms()) > 0:
buzzer.value(1); led.value(1); time.sleep_ms(200)
buzzer.value(0); led.value(0); time.sleep_ms(200)
print("Re-armed")
time.sleep_ms(50)
Give it a minute to settle after power-up and keep it away from heaters, windows and fans.
Turn the sensitivity (Sx) pot clockwise and check the module has 5 V on VCC.
Low-triggered module: invert the logic in setBuzzer().
LED is reversed; flip it. Check the 220 Ω resistor is in series.
7 parts: HC-SR501 PIR Motion Detector Sensor Module, Active Buzzer Module 3.3–5V, Through-Hole LED Pack (Pack of 10), Resistor Assortment Kit (30 Values), Raspberry Pi Pico, Solderless Breadboard (830 points) and Dupont Jumper Wires (40 pcs). Tools: Digital Multimeter and Wire Stripper and Cutter. On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 45 minutes. The build on this page has 4 steps.
No. This page has the complete, tested code (main.py).
About ₹603 for the parts at the prices on this page, plus tools if you do not have them. Quantity price breaks lower the cost when you build several.
Active vs passive buzzers; Current-limiting resistors for LEDs; Digital inputs and sensor hold time.
Ideas that reuse this build: PIR intruder alarm and Intruder SMS alert. They are listed under Take it further on this page.
Your first MicroPython project: temperature and humidity on an OLED.
A web page with ON and OFF buttons that switches a relay over Wi-Fi.
A warm ring light that fades up at dusk and down at dawn.
Turn a Pi and a touchscreen into a home command centre with a clock and to-do list.
Learning project. Check every circuit and the datasheet of each part before you power it up.