Secure Passcode Smartphone-Controlled Garage Door

by TechMartian in Circuits > Wireless

1615 Views, 20 Favorites, 0 Comments

Secure Passcode Smartphone-Controlled Garage Door

UNADJUSTEDNONRAW_thumb_b5b.jpg

This is a secure remote garage door opener controlled by your smartphone. It works by connecting to a the switch over bluetooth, which is activated upon entering the correct passcode.

Source an Outlet

UNADJUSTEDNONRAW_thumb_b5f.jpg
UNADJUSTEDNONRAW_thumb_b62.jpg

Find an outlet near the garage door switch inside your garage. If it is not close enough grab an extension cable since we will be using a smartphone power brick and a printer cable like shown in the photo above to power the Arduino and Servo Motor.

Position the Switch

UNADJUSTEDNONRAW_thumb_b60.jpg
UNADJUSTEDNONRAW_thumb_b61.jpg
UNADJUSTEDNONRAW_thumb_b63.jpg

Position the servo motor and the Arduino right next to the switch and secure it with some hot glue and tape combination. Make sure that the positioning of the servo horn is such that it collides with the switch when rotated.

Wiring

IMG_20170827_132427.jpg
IMG_20170827_132416.jpg

* Connect the brown pin to GND

* Connect the red pin to 5V

* Connect the Orange pin to pin 9.

Code

Screen Shot 2017-08-30 at 10.22.38 PM.png
Screen Shot 2017-08-30 at 10.22.40 PM.png

Change your passcode, mine is 22 but yours could be any number you choose!

#include <CurieBLE.h>
<curieble.h> #include <Servo.h><servo.h>
BLEPeripheral blePeripheral;  // BLE Peripheral Device (the board you're programming)
BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service</servo.h></curieble.h>
//set BLE characteristic
       BLEUnsignedCharCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
const int servoPin = 7;
const int passCode = 22;
Servo servo1;
 void setup()
{
  //attach servo
  servo1.attach(servoPin);
  
  // set advertised local name and service UUID:
  blePeripheral.setLocalName("Tech Martian");
  blePeripheral.setAdvertisedServiceUuid(ledService.uuid());
  // add service and characteristic:
   blePeripheral.addAttribute(ledService);
   blePeripheral.addAttribute(switchCharacteristic);
   // set the initial value for the characeristic:
    switchCharacteristic.setValue(0);
   // begin advertising BLE service:
   blePeripheral.begin();
   servo1.write (90);
 }
void loop() 
{
  // listen for BLE peripherals to connect:
 BLECentral central = blePeripheral.central();
 // if a central is connected to peripheral:
  if (central)
  {
   // while the central is still connected to peripheral:
    while (central.connected())
    {
      // if the remote device wrote to the characteristic,
      // use the value to control the LED:
      if (switchCharacteristic.written())
      {
          // any value other than 0, turn on the LED
         if (switchCharacteristic.value() == passCode) 
         {  
         servo1.write (90);     
         } 
      //else lockout for 5 minutes
       else 
      {                              
        servo1.write (180); 
        delay(5*60*1000);     
      }
      }
     }
    }
  }

Done!

IMG_2407.jpg
UNADJUSTEDNONRAW_thumb_b5d.jpg

Enjoy a more secure and convenient to open garage door!