Security has always been a concern of paramount importance to human beings. Ensuring the well-being of our personal belongings has always been near the top of our priority list. Our home is the best place where we keep our personal belongings. What about the security of our home? There is no doubt that our Door locks play a major role in keeping our home safe.
Here we are making a secure Doorlock that is completely powered by Ada. Why we use Ada here is,because it is structured, statically typed,imperative and object-oriented high level language. Ada improves code safety and maintainability by using the compiler to find errors in favor of run time errors. The brain of this Doorlock is Raspberry pi 3B. Why we are using the raspberry is that,Raspbian OS has a GNAT 6.1 available in apt-get.
This is a remote access door lock that can be controlled from any where in the world. Actually this is a client-server architecture using the sockets. The Doorlook is on the server side(Raspberry pi 3B) and the it is controlled from the client side(Raspberry pi 4).
HardwareThe Doorlock comprises of.
- Raspberry pi 3B :
Raspberry Pi 3B forms the brain of the smart door lock. It retrieves data from the client and makes the relay ON/OFF according to the data.Here in this project we are powering up the pi with the 5v 2A. The 12V can damage the raspberry pi.
- Solenoid Lock Module
This module operates at 12V 1A power supply which locks when the power is OFF and unlocks when the power is ON. It forms the physical part of the smart door lock.
- Relay:
A relay is a switching device as it works to isolate or change the state of an electric circuit from one state to another. The 12V supply is given to the electric lock module using the Relay according to the data given by the Raspberry Pi.
Gather all the necessary components.
I have used jumpers for making connections. Here we also need a Raspberry Pi 4 for controlling the door lock,actually this is the client side.This is all about the hardware section. Let's get into the software section.
SoftwareFirst we need to install gnat compiler on the raspberry. Please enter the command given below
sudo apt-get install gnat
After successfully installing the gnat compiler. Let's check the packages in the doorlock and their use cases.
COMM
: Responsible for the communication modules.COMM.CODING
: Responsible for encoding and decoding features of the communication protocol, as string from/to command types.COMM.PROCESS
: Responsible for the management of input messages decodification, and the output buffering commands.COMM.SOCKETS
: Implements the sockets layers for the client/server application. Contains the Socket Manager task.CORE
: Responsible for the high-level functions.CORE.BUFFER
: Responsible for buffering of commands to be executable.CORE.UI
: Responsible for handling the User Interfaces. The Basic UI task is contained in this package.DEVS
: Responsible for low-level devices configuration and management.DEVS.SYSFS
: Responsible for SYSFS setups and management.DEVS.SYSFS.STATIC
: Database of static objects for DEVS.SYSFS.DOORLOCK
: Contains the main application.TESTS
: To include tests and use cases.UTILS
: Set of utility functions.
This is the flow of system.
Thus, the entire system is composed by a dual MOD_WIN and MOD_RPI end-to-end open Datagram Sockets application communicating from Internet.Both MOD_WIN and MOD_RPI projects are comprised in the same project doorlock.gpr.
Project doorlock.gpr with the proper MOD_WIN will generate executable client_win.exe. This is running on the raspberry pi 4. This is the place where we are controlling the doorlock(remote access). By running this code on the terminal will the create the binary file.
sudo gprbuild -d doorlock.gpr -XPrivate_Warnings=FALSE -XModule=MOD_WIN
to execute that binary file use this code
sudo ./bin/client_win
Project doorlock.gpr with the proper MOD_RPI will generate executable server_rpi. This is running on the raspberry pi 3B.
sudo gprbuild -d doorlock.gpr -XPrivate_Warnings=FALSE -XModule=MOD_RPI
to execute binary file corresponding to this,use this code
sudo ./bin/server_rpi
The both things are running on the raspberry pi's. Let's check the demo video of the doorlock.
Apart from the ordinary turn on and turn off we can read the state of the doorlock from anywhere in the world. The entire code is given in the github repositry.
Further ImprovementsIn the upcoming updates, we like to include features like:
- Door lock break alert
- Face detection
- Face unlock
Comments