Presented here is a security system that lets you see a visitor while your main office door is locked. If you are in the middle of a meeting in a conference room and there is a visitor at the door, this system will send a notification to your smartphone with a photo of the visitor as email. If you approve, you either use your mobile or PC to unlock the front door using a Web browser. Alternatively, if you have a door bell with intercom facility, you can talk to the visitor when he or she rings the door bell. A typical block diagram of the smart receptionist with a smartlock system is shown in Fig. 1.
Interfacing circuitry of the smart receptionist and smartlock system is shown in Fig. 2. Raspberry Pi runs on standard Raspbian Linux distribution with Wi-Fi dongle, GPIO library and software written in Python language. Raspberry Pi GPIO4, GPIO17 and GPIO25 are connected with resistors R3, R2 and R1, respectively, to make logic level low.
The door bell signal from CON3 is routed to GPIO17 pin on Raspberry Pi. When a visitor rings the door bell, the status LED glows and GPIO17 becomes high. Amplitude of the door bell signal output depends on the door bell/chime used. You can use a door bell that gives 3V signal.
Captured signal should not exceed Raspberry Pi’s 3.3V limit on GPIO pins. So a 3V zener (ZD1) is used in this circuit. Ground wire of the door bell circuitry should be connected to GND pin of Raspberry Pi and the anode of status LED to GPIO17. When GPIO17 becomes high, the system captures the photo of the visitor through the webcam connected to Raspberby Pi through USB. Captured photo is sent to your email ID configured in your source program.
Open the attachment in your email and check the photo of the visitor. After your visitor is identified, either open the door directly or talk to him or her through an intercom if it is installed at the door.
When status LED glows to indicate that the door bell is ringing, press Camera tab on your Web browser (Fig. 3). This will make GPIO25 pin of Raspberry Pi high, enabling the webcam to capture the photo of the visitor. Captured photo is sent to your email ID.
After your visitor is identified, you may open the door by pressing Lock tab on the Web browser. With Lock tab pressed, GPIO4 becomes high. Since relay driver transistor T2 is connected to GPIO4, T2 conducts and energises relay (RL1). This provides a 12V DC supply from CON2 to the solenoid lock connected at CON1, and the door opens.
Get the software ready
To start with, you should have Raspberry Pi with an Internet connection. Update it to ensure that it has all the latest software and drivers. Run the command given below in the terminal to update the OS installed on Raspberry Pi.
sudo apt-get update
$ sudo apt-get upgrade
Installing WiringPi library
WiringPi is maintained under GIT, so install it with:
sudo apt-get install git-core
To obtain WiringPi using GIT:
$ git clone git://git.drogon.net/ wiringPi
If you are using clone operation for the first time, then use:
$ cd wiringPi
$ git pull origin
This will fetch an updated version and then run the build script using the command given below. To build/install, use the new simplified script given below:
$ cd wiringPi
The build script will compile and install it all for you.
Test WiringPi Installation
Run gpio command to check installation:
$ gpio -v
$ gpio readall
Setting up Apache Web server on Raspberry Pi
Apache is a popular Web server application that can be installed on Raspberry Pi to allow it to serve Web pages. On its own, Apache can serve HTML files over HTTP, and with additional modules, you can make it a dynamic Web page using scripting languages such as PHP.
Install Apache using the following:
$ sudo apt-get install apache2 php5
Find Raspberry Pi IP address using the following command:
Test your server setup of Raspberry Pi from another computer by typing its IP on any Web browser on the same or different network. You should see a message saying, “It works!” This means that Apache is working.
Changing the default Web page. The default Web page is an HTML file (index.html.) located at /var/www/html/index.html
Navigate to this directory in the terminal and have a look at what is inside.
$ cd /var/www/html
$ ls -al
This means that there is one file present inside the html directory owned by the root user. We do not need this file, so remove it.
$ sudo rm index.html
For owning the www directory, run the following command:
$ ls -l /var/www
You will see this only if you have root (the super user) privileges.
You can use the following command to change it or create a group named www-data in which you place the Pi user.
$ sudo chown -R pi /var/www
To own everything inside the directory (index.php as example), use:
$ sudo chown -R www-data /var/www
The smartfolder (inside the DVD) contains two folders, namely, html and my_project. Copy my_project inside Pi folder.
To copy html folder inside www directory, use the following command:
$ sudo cp -r /home/pi/smart/html /var/www
Now, you have a Web server ready and it will receive the Web page after refreshing it.
We have used main.py Python script to detect interrupt and call emailscript.py. Main.py gets executed when doorbell ring interrupt is received through CON3. emailscript.py Python script is used to send emails with photos as attachment.
Make necessary changes in emailscript.py. Change the text given below with your email credentials, which you will use to send emails:
USERNAME = “[email protected]”
PASSWORD = “your_password”
Change the email ID in sendMail ([“[email protected]”] with your email ID or the person who will be receiving the photo.
After everything (webcam, interfacing circuit and others) Smart Receptionist With Smartlock System has been properly connected, follow the steps given below. Run main.py Python script on the terminal by giving following command:
$ cd my_project/
$ sudo python main.py
Open the browser from another computer having an Internet connection with your Raspberry Pi IP address. You will get the Web page as shown in Fig. 3. For testing purpose, provide a 3V DC at CON3 for around three seconds and release it. Press Camera tab to get the captured photo in your email. Within a few seconds you will receive a captured photo in your email attachment in [email protected] email ID. Press Lock tab to energise the solenoid lock.