One day while kicking ideas around we arrived on the topic of connected door locks. Products in this space already exist such as Locktron, August, and Kevo. While these are all cool we thought about one feature that deterred some: being able to remotely unlock your door. Now some might say this is one of the main points of moving to a connected lock but some find it unsettling. Thus we decided to build a BLE lock that was a stripped down version allowing entry only by placing your device in range and entering a code. It’s kind of in the middle between a traditional door lock and a new IoT door lock.

 

Hardware:

  • 1 Blend Micro
  • iPod Touch 4th Gen
  • LED light
  • Square piece of acrylic
  • Breadboard

 

Our goal with this project was the require the device to be against the lock in order to enter your passcode. Thus giving it a more traditional lock feel of, “you have to be at the lock, with the key, in order to open it”. To achieve this we used the accelerometer and RSSI value of the BLE chip to determine when to show the keys.

AngleDescription

The project was written in Objective-C for the iPhone. The following method does what is shown the graphic above and determines if the keypad should be visible to the user.

- (void)startMyMotionDetect
{

    self.motionManager = [[CMMotionManager alloc] init];
    
    static CGFloat y0 = 0;

    const NSTimeInterval dt = (1.0 / 30);
    const double RC = 0.01;
    const double alpha = dt / (RC + dt);
    
    __block double y = 0.0;
    
    [self.motionManager startAccelerometerUpdatesToQueue:[[NSOperationQueue alloc] init] withHandler:^(CMAccelerometerData *data, NSError *error) {
         
         dispatch_async(dispatch_get_main_queue(), ^{
            
             y = (alpha * data.acceleration.y) + (1.0 - alpha) * y0;
             
             if (RadiansToDegrees(y) > -32) {
                 if (self.orientationEligable) {
                     self.orientationEligable = NO;
                     [self eligabilityDidChange];
                 }
             }
            
             else {
                 
                 if (!self.orientationEligable) {
                     self.orientationEligable = YES;
                     [self eligabilityDidChange];
                 }
             }
         });
     }];
}