Bluetooth enabled Door locker using Arduino


Arduino based lockers can be found on the internet where keypad was used to feed lock input. But this Bluetooth enabled Door locker uses Bluetooth as a medium to connect with the locker and your smart phone to feed input credentials. This locker allows you to lock or unlock your locker without physical touch when you are within the range of Bluetooth connection.

DESIGN:


Arduino is the heart of this locker system and HC-05 module provides the bluetooth connectivity for the arduino. I have added a relay to act as an activator for the E-locker in the above design. You may replace it with any other electronic activator or door activator if you are going to use it for doors. If that’s the case alter the design in such a way that the system is provided with enough power to drive the activator. I have added a simple LED in the project i have built-in place of Relay since i haven’t got one to use, kindly excuse me for that.

HC-05:

The HC-05 is a pretty famous Bluetooth module used in standard embedded applications where BT connectivity is required. This module converts the data received through Bluetooth and converts it into serial format that can be understood by Controllers equipped with UART communication. This module should be powered by +3.3v and special key pin for secured communication.

BT TERMINAL SOFTWARE:

A special software known as Bluetooth serial terminal is needed for this project. This software is used to send raw data from our device to the HC-05 module connected to the Arduino. This kind of software available for all smart phone platforms such as Android, iOS and Windows. I have used SENA BTerm software  Android for this project. However you can choose any Bluetooth terminal software in any platform, everything will work just fine.

FEATURES:

  1. The locker password can be set to any complex level and length with no restrictions.
  2. Bluetooth access reduces the hardware size and complexity of adding keypad to the system.
  3. Wireless activation of door locker will be the most highlighting specs of this system.
  4. Less power consumption by Bluetooth will be of great advantage.

PARTS REQUIRED:

  1. Arduino Uno
  2. HC-05 Bluetooth Module
  3. Relay
  4. Connecting Wires

ALGORITHM TO CODE:

  1. Initialize the serial communication in your Arduino.
  2. Send the Enter password prompt message via Bluetooth to the terminal.
  3. When serial interrupt occurs, fetch the data from the receiving buffer of Arduino.
  4. Look for the password match between user entered string via BT and predefined password.
  5. If match occurs send unlocked message and activate the door activator, if not send an error message and enter password message after few seconds.
  6. If the lock is opened look for serial interrupt and check for the single character command entered via BT terminal.
  7. If “L” command was entered turn off the activator, if a wrong command was entered send an error message to BT terminal.

CODE:


  1. char inbyte;
  2. String pwd="frank"; //Predefined password
  3. String inpt="";
  4. boolean lock_enable=true; //Flag to check lock status
  5. void setup() {
  6. Serial.begin(9600); //Enabling serial communication
  7. pinMode(A0, OUTPUT); //Pin to activate the door
  8. Serial.println("ENTER PASSWORD");
  9. }
  10. void loop() {
  11. if(lock_enable==true) //Activator infinite loop
  12. digitalWrite(A0, LOW);
  13. else if(lock_enable==false)
  14. digitalWrite(A0, HIGH);
  15. }
  16. void serialEvent() //Checking for serial interrupt
  17. {
  18. while(Serial.available()) //Repeat till bytes are available in buffer
  19. {
  20. inbyte=(char)Serial.read(); //Char reading
  21. delay(200);
  22. inpt=inpt+inbyte; //Changing the input character into a string
  23. inbyte='\n';
  24. }
  25. check(); //Run the password check routine
  26. }
  27. void check()
  28. {
  29. switch(lock_enable)
  30. {
  31. case true: //If the lock is enabled/locked
  32. {
  33. if(inpt==pwd) //Check for password match
  34. {
  35. lock_enable=false;
  36. Serial.println(inpt);
  37. inpt="";
  38. Serial.println("UNLOCKED"); //Display unlocked message
  39. }
  40. else if(inpt!=pwd)
  41. {
  42. Serial.println(inpt);
  43. inpt="";
  44. Serial.println("WRONG PASSWORD"); //Display error message
  45. delay(2000);
  46. Serial.println("ENTER PASSWORD"); //Prompt to enter password again
  47. delay(100);
  48. }
  49. break;
  50. }
  51. case false: //If lock is not enabled/opened
  52. {
  53. if(inpt=="L") //Check for lock command
  54. {
  55. lock_enable=true; //Change the flag and lock the door
  56. inpt="";
  57. Serial.println("LOCKED");
  58. delay(2000);
  59. Serial.println("ENTER PASSWORD");
  60. }
  61. else
  62. {
  63. inpt="";
  64. Serial.println("UNKNOWN COMMAND"); //Wrong command
  65. }
  66. break;
  67. }
  68. }
  69. }

    NOTE:

    • I have added a red LED in my built project instead of relay for indication, do not get confused.
    • You can add a different activator other than the relay provided the altered design to provide enough power for the activator .

No comments

Powered by Blogger.