learnbywatch
Play Video

Who Ring My Doorbell – RaspberryPi Home Security Project

After watching this video you will be able to:

No data was found

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

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.

What is your goal?

No data was found

7 thoughts on “Who Ring My Doorbell – RaspberryPi Home Security Project”

  1. hi, i want to ask, if i change the camera with 5mp camera module raspberry pi, is it possible for me to use the same code?

  2. if input_state == False:
    os.system(“raspistill -o image_” + str(i) + “.jpg”)
    time.sleep(0.3)
    i += 1

  3. No, you’ll need to change the last bit of the code to the following…

    if input_state == False:
    os.system(“raspistill -o image_” + str(i) + “.jpg”)
    time.sleep(0.3)
    i += 1

  4. Hi, I’ve a personnal project. I’m an electrical engineer, but my pogramming skills are wery low. I’d like to create a doorbell with my own playlist. Everytime someone pushes the button, Rpi3 would play random track from my own playlist with “repeat all” function. I was thinking about using VLC, where I can set all these things. But I don’t know how to create a code using GPIO to play next track in VLC. It’d be awesome if the program would automaticly start after boot the system together with VLC, in case of blackout or reboot. I assume the code should be quite simple for someone who knows what is he doing. I tried to search the web, but your sample is the closest what I found. Could you help me?
    Thanks

Comments are closed.

Micro Courses using this Video

No data was found
Scroll to Top
Scroll to Top