Want to build your own Real Time Clock using Arduino? Click here!
Recent Blog Posts
Arduino Alarm Clock
Arduino Alarm Clock
20/09/2017 0

IoT: Door Sensor
IoT: Door Sensor
14/09/2017 0

Getting Started with robotics and mBot
Getting Started with robotics and mBot
06/09/2017 0

IoT: Smart Intercom
IoT: Smart Intercom
30/08/2017 0

IoT: Smart Intercom

Posted by Momen 30/08/2017 0 Comment(s)

In this tutorial , I will explain how to do a smart intercom with some equipment which is  available in in Zero Ohm General Trading  in Dubai , this project is very useful for a security at companies , offices, factories and home also , it work when any person approaches to the intercom and looks at the camera , then the system will compare his face with the allowed people , if his face matched the door will open and a person can enter the place . also there is another way to open the door by place a pass card to the RFID location then if it find the code of this card on the database the door will be open .

Hardware component :

  1. Raspberry pi 3 model B
  2. RPI LCD 3.5 inch
  3. RFID reader/write module
  4. Relay SRD -05VDC-SL-C
  5. Raspberry pi camera module
  6. Two LED (generic)
  7. Wi-Fi usb dongle

Operation ( Software design ) :

First step : connect the raspberry pi 3 with the relay . in this case GPIO 12 IS used for data , and connect 5 v for power with any ground .

for test the relay with shell script , write this sample sh script :

nano open.sh

chmod +x open.sh

sh open.sh

then paste the below code and run it


script code :


echo 12 > /sys/class/gpio/export 

echo out > /sys/class/gpio/gpio12/direction

echo 0 > /sys/class/gpio/gpio12/value

ping -c 1 localhost

echo 12 > /sys/class/gpio/export 

echo out > /sys/class/gpio/gpio12/direction

echo 1 > /sys/class/gpio/gpio12/value


second step (camera connection) : connect the camera module then enable it in rasp-config by the rasp config tool from the terminal :

sudo raspi-config


then press enable camera and enter then press finnish .then to check the system if its working , write the following command :

raspistill -v -o test.jpg


third step (LED connection ) : you can connect the LED to any GPIO and ground , in this case its connect with GPIO16 (green ) and GPIO26 (red) after the connection you can test it by create 2 simple python scripts for the green and red LEDs  with the following code :

for the green LED :

from gpiozero import LED

from time import sleep

led = LED(16)

while True:






for the red LED :

from gpiozero import LED

from time import sleep

led = LED(26)

while True:






then write this to test it :

python led.py

python led2.py


if the LEDS are lighting , then everything good .

fourth step (face recognition) : use pip3 or pip2 for python 2 and install this module :

pip3 install face_recognition


the create any folder for a picture and select the pic and place the face of people you know In my case it's ("/home/pi/Documents/pic/") and ("/home/pi/Documents/unknown/").

Then create python script with the following code :

import face_recognition

import picamera

import numpy as np

import os

camera = picamera.PiCamera()

camera.resolution = (320, 240)

output = np.empty((240, 320, 3), dtype=np.uint8)

print("Loading known face image(s)")

ep_image = face_recognition.load_image_file("/home/pi/Documents/pic/ep.jpg")

ep_face_encoding = face_recognition.face_encodings(ep_image)[0]

vl_image = face_recognition.load_image_file("/home/pi/Documents/pic/vl.jpg")

vl_face_encoding = face_recognition.face_encodings(vl_image)[0]

face_locations = []

face_encodings = []

while True:

   print("Capturing image.")

   camera.capture(output, format="rgb")

   face_locations = face_recognition.face_locations(output)

   print("Found {} faces in image.".format(len(face_locations)))

   face_encodings = face_recognition.face_encodings(output, face_locations)

   for face_encoding in face_encodings:

       match = face_recognition.compare_faces([ep_face_encoding,vl_face_encoding], face_encoding)

       name = "<Unknown Person>" 

       os.system("python /home/pi/led2.py &")

       import time

       date_string = time.strftime("%Y-%m-%d-%H:%M:%S")

       camera.capture("/home/pi/Documents/unknown/image-" + date_string + ".jpg")


then if you want to test it write this code :

python facerec.py



fifth step (RFID connection ) :

pins :


Connect RFID module to raspberry pi  and write this code :

$ sudo nano /etc/modprobe.d/raspi-blacklist.conf

#blacklist spi-bcm2708

$ sudo apt-get install python-dev

$ git clone https://github.com/lthiery/SPI-Py.git

$ cd SPI-Py

$ sudo python setup.py install


When the person use a card and the script find the authorized card , it will show the user picture on the remote rpi 3 then the door will open .


import MFRC522

import signal

import os 

continue_reading = True

MIFAREReader = MFRC522.MFRC522()

cardA = [46,44,187,26,163]

cardB = [176,203,130,124,133]

cardC = [20,38,121,207,132]

def end_read(signal, frame):

 global continue_reading

 continue_reading = False

 print "Ctrl+C captured, ending read." 


signal.signal(signal.SIGINT, end_read)

while continue_reading:

 (status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)

 if status == MIFAREReader.MI_OK:

   print "Card detected" 

 (status,backData) = MIFAREReader.MFRC522_Anticoll()

 if status == MIFAREReader.MI_OK:

   print "Card read UID: "+str(backData[0])+","+str(backData[1])+","+str(back



Leave a Comment