Motion-based Door Lock system using Raspberry Pi

Call for Price

Motion-based Door Lock system using Raspberry Pi

SKU: Motion-based Door Lock system using Raspberry Pi Category:

Description

ABSTRACT

For Raspberry Pi Beginners, this project explains you about interfacing PIR Motion sensor with Raspberry Pi to control the Door lock. This system is implemented in interior door locks, which functions like opening the door when someone came near to the door. Raspberry Pi is a small sized PC, which is capable of performing every type of applications. Here PIR sensor used to detect the motion, which placed in front of the door, especially rooms having an Air conditioner. Whenever a person came in front of the door, PIR gets triggered and Raspberry Pi performs opening the door, After some defined time, the door gets automatically locked. Since we are using PIR sensor for motion detection system can able to detect the presence of humans of 180 degree

HARDWARE REQUIRED

  • Raspberry Pi
  • SD card
  • Power supply
  • VGA to HDMI converter (Optional)
  • MCP3008 (ADC IC)
  • PIR motion sensor
  • DC motor for the door lock

SOFTWARE REQUIRED

  • Raspbian Stretch OS      
  • SD card Formatter
  • Win32DiskImager (or) Etcher

PYTHON LIBRARIES USED

  • RPi.GPIO as GPIO (To access the GPIO Pins of Raspberry Pi)
  • Time library (For Time delay)

CODE

import time

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

# read SPI data from MCP3008 chip, 8 possible adc's (0 thru 7)
def readadc(adcnum, clockpin, mosipin, misopin, cspin):
    if ((adcnum > 7) or (adcnum < 0)):
        return -1
    GPIO.output(cspin, True)

    GPIO.output(clockpin, False)  # start clock low
    GPIO.output(cspin, False)  # bring CS low

    commandout = adcnum
    commandout |= 0x18  # start bit + single-ended bit
    commandout <<= 3  # we only need to send 5 bits here
    for i in range(5):
        if (commandout & 0x80):
            GPIO.output(mosipin, True)
        else:
            GPIO.output(mosipin, False)
        commandout <<= 1
        GPIO.output(clockpin, True)
        GPIO.output(clockpin, False)

    adcout = 0
    # read in one empty bit, one null bit and 10 ADC bits
    for i in range(12):
        GPIO.output(clockpin, True)
        GPIO.output(clockpin, False)
        adcout <<= 1
        if (GPIO.input(misopin)):
            adcout |= 0x1

    GPIO.output(cspin, True)

    adcout >>= 1  # first bit is 'null' so drop it
    return adcout


# change these as desired - they're the pins connected from the
# SPI port on the ADC to the Cobbler
SPICLK = 18
SPIMISO = 23
SPIMOSI = 24
SPICS = 25
doorpin1=20
doorpin2=21
# set up the SPI interface pins
GPIO.setup(SPIMOSI, GPIO.OUT)
GPIO.setup(SPIMISO, GPIO.IN)
GPIO.setup(SPICLK, GPIO.OUT)
GPIO.setup(SPICS, GPIO.OUT)
GPIO.setup(doorpin1, GPIO.OUT)
GPIO.setup(doorpin2, GPIO.OUT)

def door_open():
    GPIO.output(doorpin1, True)
    GPIO.output(doorpin2, False)
def door_close():
    GPIO.output(doorpin1, False)
    GPIO.output(doorpin2, True)
def door_stop():
    GPIO.output(doorpin1, False)
    GPIO.output(doorpin2, False)


while True:
    # read the analog pin
    PIR = readadc(0, SPICLK, SPIMOSI, SPIMISO, SPICS)
    #print("PIR_LEVEL:", PIR)       #uncomment to display pir value
    if(PIR>1000):
        door_open()
        time.sleep(1)
        door_stop()
        time.sleep(5)
        door_close()
        time.sleep(1)
        door_stop()
    else:
        door_stop()

Additional information

Weight 0.000000 kg

Reviews

There are no reviews yet.

Be the first to review “Motion-based Door Lock system using Raspberry Pi”

Your email address will not be published.

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