Arduino Bluetooth door lock access control

Hello world! Today i made a Arduino Bluetooth door lock access APP to Lock & Unlock a electrical door lock using a relay, protected by a password. The app is available open source! Just contact me! contact@arduinosensors.nl. get the APP on google PLAY!

Arduino Bluetooth door lock access control

Schematic:
Arduino Bluetooth door lock access control

Just wire it up like the schematic, Upload the Arduino Bluetooth door lock access code and download the APP on GOOGLE PLAY.
Make sure the Bluetooth module is disconnected when uploading the code! Or the arduino will get confused.
Pair devices, then connect device. Fill in the password that you set in the code and Lock or Unlock your door!

Parts list:
Arduino, RobotDyn Uno.
Bluetooth Module HC-06.
KY-019 Relay module.
2 x led1 x green 1 x red
Jumper wires set MM/FF/MF
Android Phone.

Code:

/*
Author: Danny van den Brande. Arduinosensors.nl. BlueCore Tech.
 */
String inputString = "";
String command = "";
String value = "";
String password = "fillyourpassword"; //setpassword here
                            
boolean stringComplete = false; 
int relay = 2; 
int greenLed = 5;  
int redLed = 6;    

void setup(){
  Serial.begin(9600);  // make sure it is the same baudrate as your bluetooth module 
  
  inputString.reserve(50);  
  command.reserve(50);
  value.reserve(50);
  boolean stringOK = false;
  pinMode(relay, OUTPUT);
  digitalWrite(relay, HIGH);
  pinMode(greenLed, OUTPUT);
  pinMode(redLed, OUTPUT);
  digitalWrite(redLed, HIGH);
  
}
void loop(){
  
  if (stringComplete) {
    delay(100);
    
    int pos = inputString.indexOf('=');
    
    if (pos > -1) {
      
        command = inputString.substring(0, pos);
      
        value = inputString.substring(pos+1, inputString.length()-1);  // extract command up to \n exluded
       
    if(!password.compareTo(value) && (command == "OPEN")){
          
           openDoor(); 
           Serial.println(" OPEN"); 
           delay(100);
           }
    else if(!password.compareTo(value) && (command == "CLOSE")){
         
           closeDoor();
           Serial.println(" CLOSE"); 
           delay(100);
           }
    else if(password.compareTo(value)){
         
           Serial.println(" WRONG");
           delay(100);
           } 
        } 
     
       inputString = "";
       stringComplete = false;
    }  
}
void serialEvent() {
  while (Serial.available()) {
   
    char inChar = (char)Serial.read(); 
    //Serial.write(inChar);
  
    inputString += inChar;
    
    if (inChar == '\n' || inChar == '\r') {
      stringComplete = true;
    } 
  }
}
void openDoor(){
   digitalWrite(relay, LOW);
   digitalWrite(redLed, LOW);
   digitalWrite(greenLed, HIGH);
}
void closeDoor(){
   digitalWrite(relay, HIGH);
   digitalWrite(redLed, HIGH);
   digitalWrite(greenLed, LOW);
   
}
Danny van den Brande

http://www.arduinosensors.nl

Programmer, Game Designer, 3D Designer, Web Designer, Graphic Designer. Jup this website looks crappy.. :) But enjoy the projects! Everything you need is here.

Leave a Reply

Your email address will not be published. Required fields are marked *