close-circle
Close
0%
0%

Smart Lock

Keyless entry system compatible with European door locks

Similar projects worth following
close
I couldn't find a smart lock on the market that works with my door so I decided to built it myself.
Main idea is to build a low cost and secure key-less entry system compatible with European door locks.

Challenge

There are many products available as Smart Lock on the market, few of them looks great and affordable but none of them are compatible with the European BS EN 1303: 2005 cylinder locks.

Europe door lock standards are different compared to the door lock standard of North America. Basically there is no door handle outside of the door. From the outside, the door can only be opened by using the key. Therefore, European doors have a single lock cylinder that is used to lock and open the door. Because of that, the mechanism I've built has to be completing three full turns from side to side. And also cylinder needs enough torque because of the internal mechanics and springs of the lock itself.

Objectives

  • Device must be cheap. This means no expensive motors or sensors can be used.
  • Device must be presentable. I don't want to see any cables, electronics not even the motor itself on my apartment door (since it is a very small apartment).
  • No modifications on door itself. I am a tenant at this apartment right now so I can't modify anything that can't be fixed.
  • It should be secure. Most of the RF devices are vulnerable to replay attacks, the lock should be safe enough.

Concept

Concept uses a remote device to trigger the lock cylinder to be turned 360 degrees to both lock, unlock or open the door by using an geared motor which is attached to the inner face of the door.


When I'm looking for a cheap way to position servo accurately, I've realized that I don't need to know the position of the servo. I only need to know when lock cylinder is triggering the mechanism of the lock. I know lock needs torque to trigger and torque requires enough current that I can easily measure with help of a small and cheap current sensing module. A current sensing module can be placed anywhere on the circuit and it allows me to build a more compact design.

A hall effect current sensor uses electromagnetism to calculate the current. Since voltage never goes through the sensor, you can use it in both AC and DC. Sensor gives an analog output, a voltage between 0-2.5v for negative and 2.5-5.0v for positive current readings. I can use a micro controller with an ADC to read voltage and convert it to current with a formula.

Current = Voltage You Applied / The Resistance of your Load


Micro controller

I choose ESP8266 module on NodeMCU Devkit because it handles all connectivity features that I need for this project on an single chip. It is small, cheap, it has internal ADC on it and there are ton of libraries available on the net.

LockAlgorithmFlowchart.pdf

Flowchart of the main algorithm

Adobe Portable Document Format - 95.92 kB - 05/29/2016 at 22:28

eye
Preview
download-circle
Download

SmartLock.123dx

3D sketch of the enclosure

123dx - 148.16 kB - 05/29/2016 at 16:37

download-circle
Download

MP1584.pdf

MP1584EN Step-down Converter Datasheet

Adobe Portable Document Format - 525.53 kB - 05/28/2016 at 21:41

eye
Preview
download-circle
Download

WS2812B.pdf

One wire RGB Led Datasheet

Adobe Portable Document Format - 347.03 kB - 05/28/2016 at 21:39

eye
Preview
download-circle
Download

nodemcu_pinout_700.png

NodeMCU DevKit 1.0 Pinout

Portable Network Graphics (PNG) - 306.96 kB - 05/28/2016 at 20:15

eye
Preview
download-circle
Download

View all 8 files

  • 1 × ESP8266 NodeMCU DevKit 1.0
  • 1 × Allegro ACS712 Hall Effect-Based Linear Current Sensor Module
  • 1 × Power HD AR-3606HB Continuous rotating analog servo
  • 2 × MPS MP1584EN Mini DC Buck Converter Step Down Module
  • 24 × Worldsemi WS2812B 5050 RGB LED Ring

  • Final Demo and Further Improvements

    Yiğit Topcu05/30/2016 at 00:14 0 comments

    After I've finished the build, I attached my device to the door and made some miner adjustments on threshold values. It looks like ACS712 output voltage depends on it's input voltage. Since USB voltage is lower than 5v, when I powered the device with a regulator, output analog value increased. So I re calibrated my sketch to work with 12v input of the device.

    Both Web App and led interface needs some improvements but it still enough functional for first build. Also enclosure need some white paint on become a nice fit for my door.

    Further Improvements

    • LED interface and Web App UI needs some attention
    • Enclosure is pretty damaged after too much testing and calibration. I need to replace it.
    • Diffuser affected from the heat of the ESP8266. I need rebuilt it with less layers of material.
    • Electronics still takes too much space and also consume too much power. I can use an Esp-07 module to gain some space.
    • Bluetooth is needed to automatically trigger unlock when I am close to the outside of the door.
    • I need a more secure method from just a pattern lock. I think OTP is the right way secure a device like this.

  • The Enclosure and Elecronics

    Yiğit Topcu05/29/2016 at 23:46 0 comments

    I've already made a decision to the building material while I was testing the servo on my second project log. Cardboard is the easiest material to work on. I can use household tools to cut and shape the material. The only custom tool that I need is circular cutting tool.


    The Design

    Enclosure must be a close box and there mustn't be any visible cables on the servo itself. I designed the enclosure with 9 unique parts. And Its about 790mm x 960mm.

    • Diffuser
    • Top Cap
    • Middle outer cylinder
    • Top inner cylinder
    • Servo holder ring
    • Bottom inner cylinder
    • Bottom cap
    • Door mount disk

    Attaching the servo

    I used the servo shell as template while I'm cutting the servo holder. And I have used the inner cylinder to hold this servo holder disk.

    The Diffuser

    I think the diffuser was the hardest part of the enclosure because you can't actually measure or decide how light acts on a transparent surface. Trial-and-error was the only way to build something like this. I do not want to see the individual LED's inside the box so I made a six layered transparent disk to spread enough light. Disk contains two full transparent layers both side. There are multiple plastic and paper layers at the bottom of clear layers.


    Electronics

    When I've mounted the servo, I've realized that there was not much space to put electronics in it. So I made some custom design by using standard prototype boards. I made the whole system modular so that I can replace or modify anything without building a new custom board. Basically whole board contains 7 different modules.

    Device is powered with a 12v input and it has two step-down regulators on it. One of them is set to 6v for servo and the other one outputs 5v for NodeMcu. And also there is another regulator on the NodeMcu for 3.3v requirement of the ESP8266. I know that is too inefficient but I will fix it on the next version of the device.


    Final Assembly

  • Software And UI

    Yiğit Topcu05/29/2016 at 22:27 0 comments

    After I've destroyed the most expensive part of my project, which was the servo, I've decided not to run any tests before I finish building the software. I use Visual Micro on Visual Studio as the development environment with Arduino IDE on ESP8266. You can find all the code in my GitHub repository.

    Double Current Threshold Algorithm

    When I was testing the current sensor, I've realized that there were two different thresholds. When the lock cylinder reaches at the end of mechanism, servo forces to stop and draws much more current compared to the current drawn during locking or unlocking the door. I found out that I can use the second high threshold value to determine the locks last state. And also lock will fix it's last state automatically.


    User Interface

    I've built a responsive HTML page as the user interface of the device. Browser connects to the web socket service which is hosted on the ESP8266. Than I've built a small hosted web app for my android device.

    And also, I have added a pattern lock for providing built-in security. Pattern generates a password and app uses this password to authenticate with the web socket service.

  • Destroyed The Servo With a Success

    Yiğit Topcu05/29/2016 at 19:56 0 comments

    At my first test, 6 kg servo successfully managed to turn the lock cylinder and opened the door. But after a couple turns, the servo destroyed itself. As you may notice, the servo I've choose for this project has plastic gears on it. I've found out that the plastic gears are not suitable for this kind of applications. Servo arm and it's attachment point were also damaged during the tests. This happened since there was no sensor threshold detection algorithm yet. Therefore I have to find a threshold detection algorithm before continue testing.




    Modified New Servo

    I found a metal geared servo in my small junk yard. I removed the internal electronics of the destroyed servo and mounted them to the metal geared servo shell. I also bought a metal servo arm which has side screws to mount it to the servo shaft.

  • Mounting the servo

    Yiğit Topcu05/29/2016 at 18:52 0 comments

    I was not able to calculate the exact torque needed to turn the lock cylinder but I thought a 6 kg torque servo will be enough. To test the servo, I needed a way to attach the servo to the door and I started to think about the enclosure. At first, I thought I may use a 3D printer to build the enclosure but it was not going to be cheap, because I don't have an 3D printer.


    Enclosure Material

    I found these cylindrical cardboard boxes. They have used to be the boxes of t-shirts that i bought. With 800mm of diameter, it is the perfect material to work on.


    Servo Holder

    Cardboard boxes has removable caps so I did cut an rectangle and screwed the servo using its mount points. I can use existing screws to attach another cap to the door.

    I removed the knob from the lock cylinder and used the hole on the cylinder to attach a longer pin. This long metal pin will be used to attach the servo arm to the lock cylinder.


  • Testing the current sensor

    Yiğit Topcu05/28/2016 at 21:45 0 comments

    urrent sensor provides an analog output of 0-5v; it can measure both positive and negative current. Therefore, when there is no load, sensor outputs 2.5v.

    Before I start to build the electronics and the enclosure, I have to check the sensitivity of the current sensor.

    Arduino has 5v ADC but ESP8266 works with 3.3v. I could build a simple voltage divider to lower the sensor output voltage but instead of that I connected sensor output in reverse polarity. Because servo always draw positive current, sensor output will never reach 2.5v. So when the servo is drawing current, I read a lower voltage from the ADC.


    I wrote a simple sketch to output analog value using Web Socket connection. With an help of small JavaScript library, I managed to output analog value as graph.

    Actually sensor is pretty accurate but there was too much noise on the analog input. It's impossible to determine a threshold point without using a smoothing algorithm.

    const int numReadings = 10;
    int readings[numReadings];
    int readIndex = 0;
    int total = 0;
     
    int inputPin = A0;
    
    int smoothValue() {
    	total = total - readings[readIndex];
    	readings[readIndex] = analogRead(inputPin);
    	total = total + readings[readIndex];
    	readIndex = readIndex + 1;
    	if (readIndex >= numReadings) {
    		readIndex = 0;
    	}
    	return total / numReadings;
    }

    You can find rest of the code at my GitHub repository.

View all 6 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates