Project tutorial
AirLock with Artik Cloud

AirLock with Artik Cloud © MIT

No more fumbling for keys! The Airlock is your new, intelligent, secure way to lock and unlock everything.

  • 2,915 views
  • 0 comments
  • 9 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
Hy gluegun
Hot glue gun (generic)
Lasercutter
Laser cutter (generic)
3drag
3D Printer (generic)

Apps and online services

About this project

HOW THIS PROJECT STARTED :

We have been thinking hard to expose ourselves in a product based project. And in the meantime HACKSTER was very helpful in organising their contests with Azure and Artik cloud. We actually tried our best to implement AirLock with Microsoft Azure, But because of LACK OF TIME we couldn't finish that Project.

We didn't lose hope and now, We present you the most innovative, interactive way to unlock all your stuff. That is we present you the AIRLOCK.

Our aim was to bring an INNOVATION  in the security realted area. Really liked working on a product based project. Will definitely load in some more Product Projects in the future.

Requesting you that Airlock should also be included as a project in Best ARTIK Cloud & Arduino Mashup section because we have made an innovative product by using Arduino and Artik Cloud. Hoping that you would support us in bringing this innovative product into the market.

OBJECTIVE OF THE PROJECT :

The main aim of this project was to bring about major changes in the conventional pattern locking system.

Traditionally lock has been a mechanical or electronic fastening device that is released by a physical object (such as a key, keycard, fingerprint, RFID card, security token etc.), by supplying secret information (such as a key code or password), or by a combination thereof.

On the contrary to these high cost locks, we have developed a cost efficient electronic lock, which allows the user to lock and unlock a system by drawing patterns in the air.

SIGNIFICANT KEYLESS LOCK :

This electronic lock doesn't require the user to carry a key. One has to merely remember the pattern which locks or unlocks the Safe.

USER FRIENDLY WITH WEB APP :

The Airlock is extremely user friendly, as most of us are found of pattern locks. Hence, drawing pattern in the air is exciting and easy to access. The lock can also be controlled using a web application, which will keep track of each user's login pattern.

OVERWRITING :

In order to make these patterns strong, we have added the feature to overwrite the patterns. This feature allows the user to connect even the dots which were previously connected while drawing a pattern.

SPECIFICATIONS:

  • Dimension: 15x15x20 cu.cm
  • Aluminium Frame
  • Arduino Microcontroller
  • ESP8266 WiFi Module
  • Infrared Sensors
  • Ruby on Rails
  • LEDs
  • Mortis Electronic Solenoid Lock

ALUMINIUM FRAME :

A fine, welded aluminium frame of dimensions 15x15x20 cu.cm was painted in black and used for the construction of the lock. The purpose of using aluminium frame is that it makes the lock unbreakable.

ARDUINO MICROCONTROLLER :

Arduino Uno Microcontroller is going to be used to process the analog values read from the IR Sensors and the sensor values are stored depending upon the pattern drawn. These values are later used to compare the pattern with the originally rendered pattern and then open the lock if the values match.

ESP8266 Wi-Fi MODULE :

ESP8266 will be used as the communicating device between the Web App and the Microcontroller. It is extremely small in size and thus does not occupy much space. The power consumed for transmission and reception of data is approximately 3.3V.

INFRARED SENSORS :

It has a transmitter and the receiver. The distance between the finger and the sensor, while drawing the pattern will be sent to the microcontroller and stored as array values.

RUBY ON RAILS :

A Web application will be built on Ruby on Rails, to keep track of the different patterns rendered by the different users. Each user can choose their own pattern. This Web Application can be used for adding or deleting the users. Adding users means that the person has to draw one pattern as username and another for password.

LEDs :

Red and Green LED's are going to be used to indicate whether the pattern drawn by the user is right or wrong. If the pattern is drawn green LEDs' will glow and if wrong red LEDs' will.

MORTIS ELECTRONIC SOLENOID LOCK :

A solenoid bolt is a type of electronic-mechanical locking mechanism. This type of lock is characterized by the use of a solenoid to throw the bolt. Sophisticated solenoid bolt locks may use microprocessors to perform voltage regulation, reduce power consumption, and/or provide access control.

ADVANTAGES

  • Cheap
  • Easy installation
  • Reliability
  • Durability
  • Easy retrieval of password
  • Light weight
  • Wireless
  • User friendly
  • Easy unlocking
  • Audit is maintained

CONCEPT :

We used an array of  IR sensor which acts like a tool to sense the position of the finger inside the airspace. By knowing the position of the hand and the corresponding sensor values we coded the airlock to get the value as 1,2,3 respectively on the corresponding box where the finger has been placed.

 CIRCUIT :

We used this circuit to get the values of the position of the hand. So by using this we get the password what the user wants to put and then verify it using the cloud.

AIRLOCK :

We used a simple wooden box and fitted our aluminium Airlock to it. The front side opening space is where we draw the pattern which we want to set as a password. We made the Airlock, unbreakable by any external means and made it really strong for other security purpose.

Airlock has its design as a cubical structure. It can be opened from all sides for any services that needs to be done in the future. We have made this somewhat big, but by reducing the component size inside the Airlock, we can make the Airlock size even more slimmer. It can be fitted into the wall or attached to the wall.

Since we wanted this to be a product thingy, we made sure that it looks good in appearance. So we thought of Implementing it by means of fitting the Leds in the front side to indicate the user whether he has drawn the correct password or not.

If the User draws a wrong pattern then the Red leds alone will glow. If he draws the correct pattern then the Green leds will alone light up. During Normal time all the Leds will Glow.

We used a 12V supply from external means to operate the Airlock. Thus we used the above connector to feed in the 12V supply for the Airlock. We made the Airlock a really energy efficient device which can last more days, since it needs to monitor the data always when the user enters a pattern. During the means of power cut, we have included a Battery Backup supply which is efficient for the Airlock to run for few days.

Just a connector board for the esp8266 to be fit in place and use it to make the Iot communication to the Artik cloud and log in all the details which it gets from the Airlock.

A relay board to switch between the supply voltage for efficient energy usage purpose.

The Rear side which has space to fit in all the required boards in place and all the wires. Making it a compact and lightweight was also a concern from our side. Everything can be screwed out and can be fitted in again.

The front side which houses all the sensor and collects the sensor values and sends it to the Artik cloud to further make use of the data collected from the Airlock.

We thought of a Mascot to represent our Airlock. Like the guardian to all your belongings and doors, we bring you the Airlock as a saviour.

IMPLEMENTATION OF AIRLOCK WITH ARTIK CLOUD :

We connected the airlock to the artik cloud and saw the on and off state of the airlock in the artik cloud.

We have also logged in the information of how much times the lock has been opened and closed.

Next thing is we made use of other device types to send notification to the user when the lock gets opened and closed. 

We have added the feature for the user to change his password by simply clicking a button in the airlock which requests the artik cloud to send back the data to reset the password. So it will be like a new user.

Airlock Video : 

Airlock - Making a Difference

Code

Code for AirlockArduino
Fully functional Airlock
/************************AIRLOCK 2016***********************/
/************Copyrights AIRLOCK development team************/
/********If any change, edit in Notepad++ or Sublime********/

#include<SoftwareSerial.h>
#define PASS_SIZE		10
#define NO_OF_USERS		20
#define DELAY 			100
#define DELAY_L 		400
#define DELAY_LL		2000
#define DELAY_LLL   8000
#define DEBUG			true

SoftwareSerial esp8266(9,8);

String NETWORK_NAME	=	"AKASH_SWE";
String NETWORK_PASS	=	"Akashswe30*";
String ROUTER_PORT	=	"333";
String IP 			=	"192.168.0.101";
String PORT 		=	"3000";


int avail_s1 =    425;
int avail_s2 =    669;
int avail_s3 =    610;
int avail_v1 =    305;

int n_avail_s1 =  423;
int n_avail_s2 =  660;
int n_avail_s3 =  600;
int n_avail_v1 =  305;

int lo_s1_1 =   420;          //Grid 1
int up_s1_1 =   505;

int lo_s2_1 =   645;
int up_s2_1 =   700;

int lo_s3_1 =   570;
int up_s3_1 =   612;

int lo_v1_1 =   450;

int lo_s1_2 =   430;          //Grid 2
int up_s1_2 =   505;

int lo_s2_2 =   620;
int up_s2_2 =   690;

int lo_s3_2 =   580;
int up_s3_2 =   632;

int lo_v1_2 =   330;
int up_v1_2 =   450;

int lo_s1_3 =   410;          //Grid 3
int up_s1_3 =   445;

int lo_s2_3 =   630;
int up_s2_3 =   700;

int lo_s3_3 =   585;
int up_s3_3 =   645;

int lo_v1_3 =   290;
int up_v1_3 =   327;

int lo_s1_4 =   460;          //Grid 4
int up_s1_4 =   605;

int lo_s2_4 =   605;
int up_s2_4 =   670;

int lo_s3_4 =   545;
int up_s3_4 =   575;

int lo_v1_4 =   245;
int up_v1_4 =   275;

int lo_s1_5 =   428;          //Grid 5
int up_s1_5 =   525;

int lo_s2_5 =   660;
int up_s2_5 =   790;

int lo_s3_5 =   570;
int up_s3_5 =   700;

int lo_v1_5 =   245;
int up_v1_5 =   295;

int lo_s1_6 =   410;          //Grid 6
int up_s1_6 =   425;

int lo_s2_6 =   645;
int up_s2_6 =   730;

int lo_s3_6 =   630;
int up_s3_6 =   800;

int lo_v1_6 =   250;
int up_v1_6 =   315;

int lo_s1_7 =   710;          //Grid 7

int lo_s2_7 =   610;
int up_s2_7 =   780;

int lo_s3_7 =   555;
int up_s3_7 =   600;

int up_v1_7 =   284;

int lo_s1_8 =   405;          //Grid 8
int up_s1_8 =   680;

int lo_s2_8 =   870;

int lo_s3_8 =   565;
int up_s3_8 =   860;

int lo_v1_8 =   240;
int up_v1_8 =   276;

int lo_s1_9 =   403;          //Grid 9
int up_s1_9 =   425;

int lo_s2_9 =   630;
int up_s2_9 =   800;

int lo_s3_9 =   930;

int lo_v1_9 =   245;
int up_v1_9 =   288;

void setup()
{
  //Choose the Serial baud rate
  Serial.begin(115200);
  esp8266.begin(115200);

	pinMode(A0,INPUT);
	pinMode(A1,INPUT);
	pinMode(A2,INPUT);
	pinMode(A3,INPUT);
	pinMode(3,OUTPUT);
	pinMode(4,OUTPUT);
	pinMode(5,OUTPUT);
	pinMode(6,OUTPUT);
  
	//Resetting ESP8266
  sendData("AT+RST\r\n",5000,DEBUG); // reset module
  sendData("AT+CWMODE=3\r\n",1000,DEBUG); // configure as access point

  //Connecting with WiFi
	String cwjap = "AT+CWJAP=\""+NETWORK_NAME+"\",\""+NETWORK_PASS+"\"\r\n";
	String wifi_port = "AT+CIPSERVER=1,"+ROUTER_PORT+"\r\n"; 

	sendData(cwjap, 8000, DEBUG);
	sendData("AT+CIFSR\r\n",4000,DEBUG); // get ip address
  sendData("AT+CIPMUX=1\r\n",2000,DEBUG); // configure for multiple connections
  sendData(wifi_port,3000,DEBUG);// turn on server on port 333

  //Connecting with server
	/*
  String server_connect = "AT+CIPSTART=\"TCP\",\"" + IP + "\"," + PORT + "\r\n";
	sendData(server_connect,5000,DEBUG);
	*/
  
}

int s1, s2, s3, v1;              			    //IR input variables
int UserPassword[NO_OF_USERS][PASS_SIZE];	//Checking Password array
int PassLen[NO_OF_USERS];					        //Password Length

void ReadFromIR()
{
	s1=analogRead(A0);
	s2=analogRead(A1);
	s3=analogRead(A2);
	v1=analogRead(A3);
}

void DigiWrite(bool val)
{
	digitalWrite(4,val);
	digitalWrite(3,val);
	digitalWrite(5,val);
}

int DoorOpen()
{
  digitalWrite(6,HIGH);
	digitalWrite(3,HIGH);
	digitalWrite(5,LOW);
	return 1;
}

void DoorClose()
{
  digitalWrite(6,LOW);
	digitalWrite(3,HIGH);
  delay(DELAY_LL);
  digitalWrite(3,LOW);
	digitalWrite(5,LOW);
}

void Warning()
{
  digitalWrite(5,HIGH);
  delay(DELAY_LL);
  digitalWrite(5,LOW);
}

bool IR_ready()
{
	ReadFromIR();
	return (s1 > avail_s1 || s2 > avail_s2 || s3 > avail_s3 || v1 > avail_v1);
}

bool Not_Ready()
{
	return (s1 < n_avail_s1 && s2 < n_avail_s2 && s3 < n_avail_s3 && v1 < n_avail_v1);
}

bool Grid(int n)
{
	if(n == 1)
		return (s1 > lo_s1_1 && s1 < up_s1_1 && s2 > lo_s2_1 && s2 < up_s2_1 && s3 > lo_s3_1 && s3 < up_s3_1 && v1 > lo_v1_1);
	if(n == 2)
		return (s1 > lo_s1_2 && s1 < up_s1_2 && s2 > lo_s2_2 && s2 < up_s2_2 && s3 > lo_s3_2 && s3 < up_s3_2 && v1 > lo_v1_2 && v1 < up_v1_2);
	if(n == 3)
		return (s1 > lo_s1_3 && s1 < up_s1_3 && s2 > lo_s2_3 && s2 < up_s2_3 && s3 > lo_s3_3 && s3 < up_s3_3 && v1 > lo_v1_3 && v1 < up_v1_3);
	if(n == 4)
		return (s1 > lo_s1_4 && s1 < up_s1_4 && s2 > lo_s2_4 && s2 < up_s2_4 && s3 > lo_s3_4 && s3 < up_s3_4 && v1 > lo_v1_4 && v1 < up_v1_4);
	if(n == 5)
		return (s1 > lo_s1_5 && s1 < up_s1_5 && s2 > lo_s2_5 && s2 < up_s2_5 && s3 > lo_s3_5 && s3 < up_s3_5 && v1 > lo_v1_5 && v1 < up_v1_5);
	if(n == 6)
		return (s1 > lo_s1_6 && s1 < up_s1_6 && s2 > lo_s2_6 && s2 < up_s2_6 && s3 > lo_s3_6 && s3 < up_s3_6 && v1 > lo_v1_6 && v1 < up_v1_6);
	if(n == 7)
		return (s1 > lo_s1_7 && s2 > lo_s2_7 && s2 < up_s2_7 && s3 > lo_s3_7 && s3 < up_s3_7 && v1 < up_v1_7);
	if(n == 8)
		return (s1 > lo_s1_8 && s1 < up_s1_8 && s2 > lo_s2_8 && s3 > lo_s3_8 && s3 < up_s3_8 && v1 > lo_v1_8 && v1 < up_v1_8);
	if(n == 9)
		return (s1 > lo_s1_9 && s1 < up_s1_9 && s2 > lo_s2_9 && s2 < up_s2_9 && s3 > lo_s3_9 && v1 > lo_v1_9 && v1 < up_v1_9);
}


int GetPassword(int pass[])
{
	bool grid[10] = {0};
	int len = 0;
	delay(DELAY_L);
	DigiWrite(1);
	while(1){
		ReadFromIR();
		for(int i=1; i<10; i++)
		{
			if(!grid[i] && Grid(i))
			{
				delay(DELAY);
				ReadFromIR();
				if(!grid[i] && Grid(i))
				{
					pass[len++] = i;
					grid[i] = 1;
					Serial.println(i);
				}
			}
		}
		if(Not_Ready())
		{
			DigiWrite(0);
			for(int i=1; i<10; i++)
			{
				grid[i] = 0;
			}
			break;
		}
	}
	return len-1;
}

bool PassMatches(int In[], int n, int user)
{
	for(int i=0; i<=n; i++)
	{
		if(In[i] != UserPassword[user][i])
		{
			return 0;
		}
	}
	return 1;
}

int User=0;
int user;
int FreshPassword = 0;
int DoorStatus = 0;
String Door;

int testval = 0;
int testvalid = 0;
int passright = 0;

void loop()
{
	int InPassword[PASS_SIZE] = {0};
	int InPasslen;
  
	if(esp8266.available())
	{
		//Let us assume this as to set password
		if(esp8266.find("+IPD,"))
		{
      Serial.println("Inside IPD");
			delay(300); 
			int connectionIdIPD = esp8266.read()-48;
			//Which user   is sending!
			if(esp8266.find("u="))
			{
        Serial.println("Keep the hand");
        goto Bypass;
        /*
        if(IR_ready())
        {
          User++;
          Serial.println("Entering Setting Password!");
  				PassLen[User] = GetPassword(UserPassword[User]);
          Serial.println("Password saved successfully!");
				  FreshPassword = 1;
        }
				goto CheckPass;*/
			}
			else if(esp8266.find("o="))
			{
        Serial.println("O=");
				int open = DoorOpen();
				String UserLog1 = "GET /list/make?log[userid]=Admin&log[status]=Eopen";
				String UserLog2 = "&commit=Create HTTP/1.1\r\nHost: " + IP + ":" + PORT + "\r\n\r\n";
				String cipsendlen = String(UserLog1.length()+UserLog2.length()-6);
				sendData("AT+CIPSEND="+cipsendlen+"\r\n",2000,DEBUG);
				sendData(UserLog1+UserLog2, 5000, DEBUG);
			}
     /*
			String closeCommand = "AT+CIPCLOSE=";
			closeCommand+=connectionId+"\r\n";
			sendData(closeCommand,1000,DEBUG);
			*/
		}
	} 
  
 //Testing Code
    while(Serial.available()>0){
      testval = Serial.read() - 48;
      Serial.println("Entered one");
      if(testval == 1){
Bypass: 
        User++;
        testval = 0;
        testvalid = 1;
        Serial.println("User");
        Serial.println(User);
      }
    }
    if(testvalid == 1 && IR_ready())  //if hand is inside
    {
      Serial.println("Entering Setting Password!");
      PassLen[User] = GetPassword(UserPassword[User]);
      Serial.println("Password saved successfully!");
      testvalid = 0;
    }
 //End
CheckPass: 
	if(testvalid == 0 && IR_ready())	//if hand is inside
	{
    Serial.println("Entering Getting Password!!");
		InPasslen = GetPassword(InPassword);
    Serial.println("Got test password");
		if (FreshPassword == 1)
		{
			user = User;
			goto DirectCheck;
		}
		for(user=0; user<NO_OF_USERS; user++)
		{
DirectCheck:
      passright = 0;
			if(InPasslen == PassLen[user])
			{
				if(PassMatches(InPassword, InPasslen, user))
				{
          passright = 1;
          if(DoorStatus == 0)
          {
            DoorStatus = 1;
            Door = "Open";
  					int open = DoorOpen();
            Serial.println("************************");
            Serial.println("User");
            Serial.println(user);
            Serial.println("Door Opened");
            Serial.println("************************");
          }
          else
          {
            DoorClose();
            Door = "Close";
            DoorStatus = 0;
            Serial.println("************************");
            Serial.println("User");
            Serial.println(user);
            Serial.println("Door Closed");
            Serial.println("************************"); 
          }

         
          
          /*sendData("AT+CIPSTART=\"TCP\",\"192.168.0.101\",3000\r\n",5000,DEBUG);
          sendData("AT+CIPSEND=99\r\n",2000,DEBUG);
          int connectionId = esp8266.read()-48;
          String sam = "GET /list/insert?log[userid]=1&list[status]=1&commit=Create HTTP/1.1\r\nHost: 192.168.0.101:3000\r\n\r\n";
          sendData(sam,5000,DEBUG);
          String closeCommand = "AT+CIPCLOSE=";
          closeCommand+=connectionId;
          closeCommand+="\r\n";
          sendData(closeCommand,3000,DEBUG);*/
          
          //String server_connect = "AT+CIPSTART=\"TCP\",\"" + IP + "\"," + PORT + "\r\n";
          //sendData(server_connect,5000,DEBUG);
          //Serial.println(Door);
					//String UserLog = "GET /list/insert?log[userid]="+ String(user) +"&log[status]="+Door+"&commit=Create HTTP/1.1\r\nHost: "+IP+":"+PORT+"\r\n\r\n";
          //String UserLog = "GET /list/insert?log[userid]=1&log[status]=1&commit=Create HTTP/1.1\r\nHost: 192.168.0.101:3000\r\n\r\n";
          //String cipsendlen = String(UserLog.length()-6);
          //Serial.println(UserLog);
          //Serial.println(UserLog.length());
          //Serial.println(cipsendlen);
					//sendData("AT+CIPSEND="+cipsendlen+"\r\n",2000,DEBUG);
					//sendData(UserLog, 5000, DEBUG);
          //String closeCommand = "AT+CIPCLOSE=";
          //closeCommand+=connectionId;
          //closeCommand+="\r\n";
          //sendData(closeCommand,3000,DEBUG);
          
				}
			}
      if (passright == 1)
      {
         FreshPassword = 0;
         break;
      }
		}
    if(passright != 1)  //WRONG PASSWORD
    {
          Warning();
          Serial.println("************************");
          Serial.println("WRONG PASSWORD!");
          Serial.println("************************");
    }
	}
}

//DO NOT CHANGE ANYTHING BELOW THIS

String sendData(String command, const int timeout, boolean debug)
{
	String response = "";
	esp8266.print(command); // send the read character to the esp8266
	long int time = millis();
	while( (time+timeout) > millis())
	{
		while(esp8266.available())
		{ 
			char c = esp8266.read(); // read the next character.
			response+=c;
		}  
	}
	if(debug)
	{
		Serial.print(response);
	}
	return response;
}
Calibrating Airlock sensor valuesArduino
Helps to Calibrate the sensor values.
void setup() 
{
 Serial.begin(9600);
 pinMode(A0,INPUT);
 pinMode(A1,INPUT);
 pinMode(A2,INPUT);
 pinMode(A3,INPUT);
 pinMode(A4,INPUT);
 pinMode(A5,INPUT);
 pinMode(3,OUTPUT);
 pinMode(4,OUTPUT);
 pinMode(5,OUTPUT);
}
int s1,s2,s3,v1;
void loop() 
{
 digitalWrite(3,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  s1=analogRead(A0);
  s2=analogRead(A1);
  s3=analogRead(A2);
  v1=analogRead(A3);
  Serial.println(s1);
  Serial.println(s2);
  Serial.println(s3);
  Serial.println(v1);
  Serial.println();
  Serial.println();
  Serial.println();
  delay(1000);
}
Artik Cloud using Curl for AirlockJSON
curl -H "Content-Type: application/json" -H "Authorization: Bearer 687dc03a09374c33b7cbcde5cc7b6594" "https://api.artik.cloud/v1.1/users/self"

Custom parts and enclosures

Airlock Design
After the welding stage, the complete Airlock.
Img 20160913 wa0010

Schematics

Airlock Ir Array
Airlock gets the values from these IR array setup.
Photo 2016 09 30 14 29 33

Comments

Similar projects you might like

IoT Command Center - Using Samsung ARTIK Cloud

Project in progress by CJA3D

  • 3,731 views
  • 1 comment
  • 23 respects

Monitor Fire and Temperature Using ARTIK Cloud

Project tutorial by Samsung IoT

  • 2,585 views
  • 0 comments
  • 21 respects

Send Tweets Using Arduino with Artik Cloud

Project tutorial by Jasper

  • 1,651 views
  • 0 comments
  • 9 respects

Water Quality Monitoring Using MKR1000 and ARTIK Cloud

Project tutorial by Team Animo!

  • 7,075 views
  • 12 comments
  • 30 respects

HBus Home Automation And Artik

Project tutorial by Vincenzo

  • 2,447 views
  • 0 comments
  • 6 respects

Smart Home - Smart Rules using ARTIK Cloud & Photon

Project tutorial by Raghavendra Ponuganti

  • 4,102 views
  • 2 comments
  • 13 respects
Add projectSign up / Login