Ferrithemaker has published a new Raspberry Pi project to the Hackster.io website this week, providing details on how you can create your very own DIY Raspberry Pi intruder alarm and detection system. This project is suitable for both masters and intermediate makers, and it should keep you busy for at least four hours. The system has been built using the Raspberry Pi 3 mini PC together with a PIR motion sensor, the official Raspberry Pi camera module, and a pair of speakers.
Project Overview
In this project, you will create an intruder detection device that will check if somebody is inside your house or room when you are out using a PIR sensor. If the PIR sensor detects somebody, it will take a set of pictures of the intruder. The pictures will be sent to your Telegram bot channel wherever you are. You can also add some “scare away” tactics, like triggering an alarm sound or a pre-recorded voice message.
The Raspberry Pi 3 mini PC is an excellent choice for this project due to its compact size and powerful capabilities. The PIR motion sensor is a passive infrared sensor that detects motion by measuring changes in infrared radiation levels. When the sensor detects motion, it sends a signal to the Raspberry Pi, which then activates the camera module to capture images of the intruder.
Components and Setup
To build this intruder detection system, you will need the following components:
– Raspberry Pi 3 mini PC
– PIR motion sensor
– Official Raspberry Pi camera module
– Pair of speakers
– MicroSD card with Raspbian OS installed
– Power supply for Raspberry Pi
– Breadboard and jumper wires for connections
First, connect the PIR motion sensor to the Raspberry Pi. The sensor has three pins: VCC, GND, and OUT. Connect the VCC pin to the 5V pin on the Raspberry Pi, the GND pin to a ground pin, and the OUT pin to a GPIO pin (e.g., GPIO 17). Next, connect the camera module to the Raspberry Pi using the camera interface (CSI) port. Ensure that the camera module is securely connected and enabled in the Raspberry Pi configuration settings.
For the speakers, you can use the 3.5mm audio jack on the Raspberry Pi or connect USB speakers. The speakers will be used to play alarm sounds or pre-recorded voice messages to scare away intruders.
Software and Configuration
Once the hardware setup is complete, you will need to install and configure the necessary software. Start by updating the Raspbian OS and installing the required libraries:
“`bash
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3-pip
pip3 install picamera
pip3 install telepot
“`
Next, create a Telegram bot and obtain the bot token. You can do this by chatting with the BotFather on Telegram and following the instructions to create a new bot. Once you have the bot token, you can use it to send messages and images to your Telegram channel.
Create a Python script to handle the motion detection and image capture. The script should monitor the PIR sensor for motion, capture images using the camera module, and send the images to your Telegram bot channel. Additionally, you can add code to play alarm sounds or voice messages through the speakers.
Here is a basic example of the Python script:
“`python
import RPi.GPIO as GPIO
import time
import picamera
import telepot
# Set up GPIO
PIR_PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIR_PIN, GPIO.IN)
# Set up camera
camera = picamera.PiCamera()
# Set up Telegram bot
bot = telepot.Bot(‘YOUR_BOT_TOKEN’)
def handle_motion(PIR_PIN):
print(“Motion detected!”)
camera.capture(‘/home/pi/intruder.jpg’)
bot.sendPhoto(‘YOUR_CHAT_ID’, photo=open(‘/home/pi/intruder.jpg’, ‘rb’))
# Add code to play alarm sound or voice message
try:
GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=handle_motion)
while True:
time.sleep(1)
except KeyboardInterrupt:
print(“Quit”)
GPIO.cleanup()
“`
This script sets up the GPIO pins, initializes the camera, and configures the Telegram bot. When motion is detected, the script captures an image and sends it to the specified Telegram chat.
“In this project, you will create an intruder detection device that will check if somebody is inside your house/room when you are out using a PIR sensor. If the PIR sensor detects somebody, it will take a (set of) picture(s) of the intruder. The pictures will be sent to your Telegram bot channel wherever you are. You can also add some “scare away” tactics, like triggering an alarm sound or a pre-recorded voice message.”
Source: Hackster.io
Latest Geeky Gadgets Deals
Disclosure: Some of our articles include affiliate links. If you buy something through one of these links, Geeky Gadgets may earn an affiliate commission. Learn about our Disclosure Policy.