Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR -Smart door lock; plz review it #2

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images and Videos/Images/PCB Design 1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images and Videos/Images/PCB Design 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images and Videos/Images/PCB Design 3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images and Videos/Images/PCB Design 4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images and Videos/Videos/Working Video.mp4
Binary file not shown.
Binary file added Poster and Report/Poster.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 76 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,76 @@
# Smart-door-locking-system
# Smart-door-locking-system

#### Open Project 2022

## Abstract

The aim of this project is to open a Smart door lock from any where in the world by using IOT cloud or by using Keypad. The goals of this project was to build a modern, easy-to-use, smart door lock that allows for accessible unlocking and adds convenience, utility, and security to your home.

## Motivation

Ever felt lazy to go and open the door when you listen to door bell? Or tired of carrying keys all over and afraid of loosing them ?. To provide an easy and convenient method for unlocking a door by removing the need for the old-fashioned key. And the time that is requires to open the door using IOT is less than time required to open with normal key. And it also ensure more security for our lock.

## Mechanical Aspect of the Design

The actuator used in this project s a 12V Solenoid Lock Actuator. It is a ready-made lock like desin which just as to be fitted in the casing. A case for this has to be made. This need to be done on Solidworks and get it 3D printed. The casing has to be as compact as possible and must fit the PCB, actuator ,etc. Due to time constraints it has not been made.

## Electronics Aspect of the Design

### Components

* Nodemcu ESP 8266 - ESP 8266 : This is used as Wi Fi module to connect the door lock through IoT. It is used to connect to Arduino IoT cloud and send the data from Cloud to Arduino (or vice versa).
* Arduino UNO - This is used to control the door lock and take input through keypad and act on the lock. This is main controlling unit of lock.
* Solenoid Lock Actuator - Linear solenoids basically consist of an electrical coil wound around a cylindrical tube with a ferro magnetic actuator or “plunger” that is free to move or slide “IN” and “OUT” of the coils body. They are useful in many applications that require an open or closed (in or out) type motion. In this case it moves IN when power is supplied and is in OUT state when there’s no power.
* Keypad - Keypad : This is to use ‘password’ based unlocking. Who wants to take out mobile if one is at the door!? We’ve used 4*4 keypad.
* 5V Single relay module
* 12V rechargeable Li-ion Battery
* 12V Charger
* Some diodes, Resistors, Connecting wires
* PCB designing

<p align="center"><img width="674" alt="Final ckt" src="https://user-images.githubusercontent.com/109852675/180622980-73ec9dae-7ab8-48cd-b12d-f95311ac56dc.png"></p>

### Working

First of all, a request to open door lock is sent from Arduino IoT cloud Dashboard. The request is then sent to Nodemcu ESP 8266 via internet. For this Nodemcu must be connected to Wi Fi with internet. Nodemcu then transfers the request to open the door to Arduino UNO by serial communication through Rx and Tx pins. Arduino UNO on the basis of request opens or closes the lock. The door lock automatically closes after 10 seconds of opening.

<p align="center"><img width="727" alt="Workflow" src="https://user-images.githubusercontent.com/109852675/180622842-15ab47f4-2f1a-4038-b57d-8b78ae5e9c49.png"></p>


## Cost Structure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cost of components should be in a table.

----------------------------
components |  Price |
----------------------------


|Solenoid Actuator | 500/- |
|:--- |:--- |
|Arduino Uno | 500/- |
|NodeMCU ESP8266 | 350/- |
|Other costs (Adapters, batteries etc)| 700/- |
|Total | 2050/-|

## Applications

* This project has various applications in daily life. Now a days people are too busy and they want to make an advantage of resources in various aspects.
* If you are having only one key to a house then the main problem here is other person of the house may not have the keys, so by using this IOT cloud many people can access the door lock.
* Disabled or elder people can easily access the door using their mobile phones.And it also ensures high security to the lock.

## Limitations

* The main problem here is if both battery and charging management got failed. Then it is difficult to open the lock.
* Also Hackers can hack the access to get into the house. We need to keep extra access for Guests, during that period our code can be shared to other people.
* Reliance on Smart Phones. If we lost our mobile and if we dont have any back up option, then we may fall into trouble.
* It Costs Heavily and if some problem occurs we need to contact for help.

## Furter Improvements

* The circuit could be made compact by PCB printing. Also the casing can be done by printing the solid work model.
* LCD Display can be used to show the status of password, lock and other stuff.
* IOT code can be upgraded to store time of door opening in th cloud.
* The Lock can be integrated mechanically with modern door handle.

## Team Members

1. [Manmanth Ashtikar](https://github.com/ashtikarmanmath).
2. [Varanasi Chakradhar](https://github.com/Chakri2507).

## Mentor

1. Nishant Kumar
115 changes: 115 additions & 0 deletions src/Arduino code/Arduino code.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#include "Keypad.h"
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns

char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

int data=12;
byte rowPins[ROWS] = {9,8,7,6};
byte colPins[COLS] = {5,4,3,10};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
const int len_key = 5;
char master_key[len_key] = {'1','2','3','4','1'};
char attempt_key[len_key];
int z=0;

void setup() {
pinMode(12, OUTPUT);
digitalWrite(12, LOW);
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
while(!Serial);
Serial.println("Serial Mil gya..!");
}

void loop() {
if(Serial.available()){
int state= Serial.parseInt();
if( state==1){
Serial.println("State variable changed to 1");
digitalWrite(12, HIGH);
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("Door is being unlocked");
}
else {
Serial.println("State variable changed to 0");
digitalWrite(12, LOW);
digitalWrite(LED_BUILTIN, LOW);
Serial.println("Door is being locked");

}
}

keypadcheck();

}
void keypadcheck(){


char key = keypad.getKey();

if (key){
switch(key){
case '*':
Serial.println("Clicked *");
z=0;

break;
case '#':
delay(100);
Serial.println("Checking key");
// added debounce

checkKEY();
Serial.println("Key has been checked");
break;
default:
attempt_key[z]=key;
Serial.println("Writing element");

z++;
}
}
}


void checkKEY()
{
int correct=0;
int i;
for(int i=0;i<len_key;i++){
Serial.println(attempt_key[i]);}
for (i=0; i<len_key; i++) {
if (attempt_key[i]==master_key[i]) {
correct++;
}
}
if (correct==len_key && z==len_key){
Serial.println("Correct pin");
digitalWrite(12, HIGH);
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("Door is being unlocked");
delay(10000);
digitalWrite(12, LOW);
digitalWrite(LED_BUILTIN, LOW);
Serial.println("Door is being locked");
delay(3000);
z=0;
Serial.println("Now insert pin");
}
else
{
Serial.println("Incorrect pin entered");
delay(3000);
z=0;
Serial.println("Insert pin");
}
for (int zz=0; zz<len_key; zz++) {
attempt_key[zz]=0;
}
}
77 changes: 77 additions & 0 deletions src/NodeMCU code/Untitled_jun16a/Main file(open this).ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include "arduino_secrets.h"
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/2dc22a3d-a18f-4d29-b470-c2429d0bf379

Arduino IoT Cloud Variables description

The following variables are automatically generated and updated when changes are made to the Thing

bool lock;

Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include<SoftwareSerial.h>
SoftwareSerial abc(13, 15);

void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);

// Defined in thingProperties.h
initProperties();

// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);

/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
abc.begin(9600);
}

void loop() {
ArduinoCloud.update();
onLockChange();
// Your code here


}

/*
Since Lock is READ_WRITE variable, onLockChange() is
executed every time a new value is received from IoT Cloud.
*/
void onLockChange() {
// Add your code here to act upon Lock change
//int i=0;
if(lock==true){
//i=1;
abc.write("1");
Serial.println("Request to open sent");
//i=0;

delay(10000);
lock= false;
Serial.println("IoT variable lock set to false after 10s");

abc.write("0");
Serial.println("Request to close sent now");

}
else if (lock==false) {abc.write("0");

}
}
58 changes: 58 additions & 0 deletions src/NodeMCU code/Untitled_jun16a/ReadMe.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
:Author: manmathashtikar
:Email:
:Date: 16/06/2022
:Revision: version#
:License: Public Domain

= Project: {Project}

Describe your project

== Step 1: Installation
Please describe the steps to install this project.

For example:

1. Open this file
2. Edit as you like
3. Release to the World!

== Step 2: Assemble the circuit

Assemble the circuit following the diagram layout.png attached to the sketch

== Step 3: Load the code

Upload the code contained in this sketch on to your board

=== Folder structure

....
sketch123 => Arduino sketch folder
├── sketch123.ino => main Arduino file
├── schematics.png => (optional) an image of the required schematics
├── layout.png => (optional) an image of the layout
└── ReadMe.adoc => this file
....

=== License
This project is released under a {License} License.

=== Contributing
To contribute to this project please contact:

=== BOM
Add the bill of the materials you need for this project.

|===
| ID | Part name | Part number | Quantity
| R1 | 10k Resistor | 1234-abcd | 10
| L1 | Red LED | 2345-asdf | 5
| A1 | Arduino Zero | ABX00066 | 1
|===


=== Help
This document is written in the _AsciiDoc_ format, a markup language to describe documents.
If you need help you can search the http://www.methods.co.nz/asciidoc[AsciiDoc homepage]
or consult the http://powerman.name/doc/asciidoc[AsciiDoc cheatsheet]
3 changes: 3 additions & 0 deletions src/NodeMCU code/Untitled_jun16a/arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define SECRET_SSID ""
#define SECRET_PASS ""
#define SECRET_DEVICE_KEY ""
22 changes: 22 additions & 0 deletions src/NodeMCU code/Untitled_jun16a/sketch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"cpu": {
"fqbn": "esp8266:esp8266:nodemcuv2:baud=115200,dbg=Disabled,eesz=4M,exception=disabled,ip=lm2f,lvl=None____,vt=flash,wipe=none,xtal=80",
"name": "NodeMCU 1.0 (ESP-12E Module)",
"type": "serial"
},
"secrets": [
{
"name": "SECRET_SSID",
"value": ""
},
{
"name": "SECRET_PASS",
"value": ""
},
{
"name": "SECRET_DEVICE_KEY",
"value": ""
}
],
"included_libs": []
}
24 changes: 24 additions & 0 deletions src/NodeMCU code/Untitled_jun16a/thingProperties.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Code generated by Arduino IoT Cloud, DO NOT EDIT.

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

const char DEVICE_LOGIN_NAME[] = "bd95aeec-8969-4784-8675-a7cdd2077f8d";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"DEVICE NAME"


const char SSID[] = SECRET_SSID; // Network SSID (name)
const char PASS[] = SECRET_PASS; // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[] = SECRET_DEVICE_KEY; // Secret device password

void onLockChange();

bool lock;

void initProperties(){

ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
ArduinoCloud.addProperty(lock, READWRITE, ON_CHANGE, onLockChange);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);