To Program An Automatic Door Unlock System Using Face Recognition

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Reg no: 19BEC1402 Lab_Experiment_5

Name: Vivekanandan V Date: 01/10/2021

Face Recognition- Automatic Door


Unlock System

Aim:

To program an Automatic Door unlock system using face recognition.

Software Required:

Google Colaboratory (Programmed in Python)


Tinkercad

Tinkercad Circuit:
Colab Code:
Tinkercad Code:

#include<string.h>
//Make sure to subscribe :)
String ssid = "Simulator Wifi"; // SSID to connect to
String password = ""; // Our virtual wifi has no password (so dont do your banking stuff on this network)
String host = "api.thingspeak.com"; // Open Weather Map API
const int httpPort = 80;
String uri = "https://api.thingspeak.com/channels/1530449/fields/1.json?
api_key=4WLODSKYM13JZLWP&results=2";
int motor = 10;
int buz = 9;

int setupESP8266(void) {
// Start our ESP8266 Serial Communication
Serial.begin(115200); // Serial connection over USB to computer
Serial.println("AT"); // Serial connection on Tx / Rx port to ESP8266
delay(10); // Wait a little for the ESP to respond
if (!Serial.find("OK")) return 1;

// Connect to 123D Circuits Simulator Wifi


Serial.println("AT+CWJAP=\"" + ssid + "\",\"" + password + "\"");
delay(10); // Wait a little for the ESP to respond
if (!Serial.find("OK")) return 2;

// Open TCP connection to the host:


Serial.println("AT+CIPSTART=\"TCP\",\"" + host + "\"," + httpPort);
delay(50); // Wait a little for the ESP to respond
if (!Serial.find("OK")) return 3;

return 0;
}

void anydata(void) {

// Construct our HTTP call


String httpPacket = "GET " + uri + " HTTP/1.1\r\nHost: " + host + "\r\n\r\n";
int length = httpPacket.length();
//String httpPacket = "GET https://api.thingspeak.com/channels/1104800/fields/1.json?
api_key=U16ZA1ADIPFY66YS&results=2";
//int length = httpPacket.length();
// Send our message length
Serial.print("AT+CIPSEND=");
Serial.println(length);
delay(10); // Wait a little for the ESP to respond if (!Serial.find(">")) return -1;

// Send our http request


Serial.print(httpPacket);
delay(10); // Wait a little for the ESP to respond
String ch;
ch = Serial.readString();
Serial.println(ch);
int point = 0;
for(int i = 0 ;i<500 ; i++)
{
if(ch[i]=='x')
{

point = i+1;
break;

}
}
Serial.println(ch[point]);
if(ch[point]=='y')
{
Serial.println("Access Granted");
digitalWrite(motor,HIGH);
delay(6000);
digitalWrite(motor,LOW);
}
else
{
Serial.println("Access denied");
digitalWrite(buz,HIGH);
delay(6000);
digitalWrite(buz,LOW);
}

if (!Serial.find("SEND OK\r\n")) return;

void setup() {

setupESP8266();
pinMode(motor,OUTPUT);
pinMode(buz,OUTPUT);
}

void loop() {

anydata();

delay(1000);
}

Inference:
From the above code and outputs in
CASE 1:
 In Google Colaboratory - I have captured my photo and the program has
 recognised my face and welcomed me with “hi Vivek”.
 In Tinkercad we see the message “Welcome” in the Serial Monitor.
CASE 2:
 In Google Colaboratory- the image captured is that of some stranger and
it
 displays “Wait a minute who are you”. Since that image hasn’t been
 recorded, the program isn’t able to recognise the new face.
 In Tinkercad we see the message “Access Denied” on the Serial Monitor.

Output:
Result:

Hence, the required outputs have been generated and verified.

You might also like