Who Ring My Doorbell – RaspberryPi Home Security Project

2
1478

Do you want to know who ring your doorbell when you are away from your home? If your answer is yes then this video is for you. You will attach a camera to RaspberryPi and whenever a person presses the doorbell, RaspberryPi takes a photo and put it into a folder that is in sync with Google Drive. This way you will get the picture on your smartphone.

You need following components in order to make this project.

Step 1: Setup Raspberry Pi

This post will help you to setup RaspberryPi with an operating system and required hardware. Install overgrive and configure it by following instructions given here.

Step 2: Attach Camera

Connect camera to a USB port of RaspberryPi and install fswebcam application to RaspberryPi with this command. Open terminal and run following command.

sudo apt-get install fswebcam

Check if camera is working. Run the following command and check if camera is taking picture or not.

fswebcam -r 1280x720 -S image1.jpg

If camera is working you will not get any error and an image named image1.jpg will be created in current directory. Open image1.jpg and if you see an image the camera is working perfectly and you can go ahead.

Step 3: Connect button to Raspberry Pi

Connect ground port of the pin to ground pin of Raspberry Pi and other port of the button to Pin 18 (physical pin 12).

Step 4: Source Code

# import the necessary packages
import time
import sys, os
import RPi.GPIO as GPIO

# Use BCM GPIO references
# instead of physical pin numbers
GPIO.setmode(GPIO.BCM)

# Define GPIO signals to use
# Physical pins 12
# GPIO18
pin_button = 18
GPIO.setup(pin_button, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# allow the camera to warmup
time.sleep(0.5)
i=0
while True:
    input_state = GPIO.input(pin_button) # Sense the button
    
    if input_state == False:
        os.system("fswebcam -r 1280X720 -S 15 image_" + str(i) +".jpg")
        time.sleep(0.3)
        i += 1

You can download the source code from the link given below.

Download “Door Alert” doorAlert_2.zip – Downloaded 132 times – 467 B

Run this program with the following command in terminal.

python doorAlert_2.py

Step 5: Test the project

if all components are properly connected and the program is error free then the camera will take the photo on every button press.

I believe that you will successfully make this project. You should have basic knowledge of Linux operating system and Python programming language. Still, if you face any problem ask in the comment box.

Required Material to make it yourself


Ph.D. (IIT Bombay), M.Tech., B.Tech. (CSE) Dr. Yogendra Pal finished his Ph.D. from Educational Technology department at IIT Bombay. Mr. Pal holds B.Tech. and M.Tech. Degrees in Computer Science and Engineering. His interests include programming, web development, graphic design and educational technology.

2 COMMENTS

    • All you need to learn how to use camera module with Raspberry Pi. Everything else will remain same. At present we don’t have video for camera module but you can search on the internet, you will find many.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.