How to Make an Easy Motion Detection System with Raspberry Pi Pico and OLED Display

Hello and welcome back. In this project, we will learn how to make a Motion detection security system with Raspberry Pi Pico. The main part of this system is a PIR motion sensor, which helps detect any movement. It’s a great option because it’s low-cost and provides good accuracy. Also, the PIR sensor triggers alerts when motion is detected, making it a great choice for home security applications. Additionally, I’ve also added an OLED display to show the system status, a buzzer to give sound alerts, and an LED to show when motion is detected.
Especially, I designed a custom PCB using JLCPCB, which helps keep everything neat and organized. Therefore, we don’t need any wires for this project. Also, you can power this system using the USB cable or external 5VDC power supply. Finally, I want to say, this project is perfect if you’re looking for a simple and affordable way to improve home security. If you want to learn more about the PIR motion sensor and how to use it step by step, please check out this guide.
- How to use the OLED display – Click on me
- What is the Raspberry Pi Pico, and how can you set it up step by step? — Click on me
Ok, let’s do this project step by step. The required components are given below.
- Raspberry Pi Pico board x 1 — Our store / Amazon
- OLED display x 1 — Our Store / Amazon
- PIR sensor x 1 — Our Store / Amazon
- LED bulb x 1 — Our Store / Amazon
- 100-ohm Resistor x 1 — Our store / Amazon
- 5v Active buzzer x 1 — Our store / Amazon
- Female header x 2 — Our store / Amazon
- Two-pin terminal x 1 — Our store / Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.








Step 2
Secondly, let’s order the PCBs for our motion detection system. Follow these simple steps to get started.
- First, go to the JLCPCB official website and log in to your account. If you are a new customer, please use my link here to register and get $60 new user coupons.


- Click the “Instant Quote” button and upload the Gerber file, which you can download using the link below.
- Gerber file — Download
- I ordered five red PCBs for this project. Next, choose your preferred build time and shipping options, then click “Save to Cart” to proceed.





Step 3
Third, unbox your PCB package and inspect the quality of the PCBs. You’ll be able to recognize the high quality of these PCBs.






Step 4
Next, solder all the components onto the PCB. Once done, you’ll have the main board for your project ready.







Step 5
Now, connect the Raspberry Pi Pico board, OLED screen, and PIR sensor to the female headers. After that, plug the Raspberry Pi Pico into your computer.




Step 6
Next, copy and paste the Python script below into the Thonny IDE. I’ve explained each line of the code, so you’ll have a better understanding of how it works. Additionally, make sure to set up your Thonny IDE for MicroPython in this step. If you haven’t done so yet, please refer to this tutorial.
- Python Script — Download
from machine import Pin, I2C
from time import sleep
from ssd1306 import SSD1306_I2C
# Pin assignments
LED = Pin(2, Pin.OUT)
Buzzer = Pin(4, Pin.OUT)
PIR = Pin(3, Pin.IN)
# Set up I2C for OLED (SDA on GPIO 6, SCL on GPIO 7)
i2c = I2C(1, sda=Pin(6),scl=Pin(7), freq=400000)
# Initialize OLED display (128x64 resolution)
oled = SSD1306_I2C(128, 64, i2c)
def clear_display():
oled.fill(0) # Clear the display
oled.show()
# Display the initial message before starting the dots
oled.fill(0) # Clear the display
oled.text("System Starting", 5, 0)
oled.show()
sleep(1)
# Show the dots one by one
message = "Loading"
x_pos = 30 # Starting position for dots
for i in range(5): # 3 dots
oled.text(message + "." * (i+1), x_pos, 30)
oled.show() # Update the display to show the dots
sleep(0.7) # Wait a bit before displaying the next dot
# Clear display after the startup message
clear_display()
# Main loop
while True:
oled.text("*****************", 0, 0)
oled.show()
if PIR.value() == 1:
# Motion detected
LED.value(1)
Buzzer.value(1)
oled.fill(0) # Clear previous display
oled.text("Motion Detected!", 0, 35) # Display message
oled.show()
else:
# No motion detected
LED.value(0)
Buzzer.value(0)
clear_display() # Clear the display
sleep(0.1) # Small delay for stability
- Next, include the ssd1306 package. To do this, go to the “Manage Packages” option in Thonny IDE and install the ssd1306 package.



- Afterward, save the script to the Raspberry Pi Pico board, making sure to name it main.py. Finally, click the Run button to execute the script.




Step 7
Now you can test the system using either USB power or an external 5V DC power supply. Enjoy your project! The full video guide is available below. So we hope to see you in the next project. Have a great day!


How to Make a Easy Motion Detection System with Raspberry Pi Pico and OLED Display