Learn By Watch Exit Reader Mode

Who Ring My Doorbell – RaspberryPi Home Security Project

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

# 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
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")
        i += 1

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

Download “Door Alert” doorAlert_2.zip – Downloaded 332 times –

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