Keyless Unlock System

Introduction: Keyless Unlock System

About: Electronic Hobby Store

Created by Simon Lee

Overview:

This project is designed to keylessly lock and unlock the door by knocking. The device makes it convenient for the user since the user does not need a key to lock the door especially when the user is racing against time. Users can unlock the door by using a secret knock, the secret knock pattern can easily be changed by a user.

Supplies

Step 1: Setup Piezo Sensor

Piezo sensor converts press or squeeze into measurable electrical charges. By observing the value of the electrical charges, the knocking pattern can be extracted. The circuit of the piezo sensor shows above, the piezo sensor connected parallelly with a 1M Ohm resistor and to the ground and analog pin on the Arduino UNO.

Step 2: Setup Push Button

The function of the push button is to change the knock password, when the push button is pressed and held, the system will erase the existing knock password, meanwhile, the system records the knocks pattern until the button has been released. The system records the new knock pattern and saves it as a new password. The circuit of the button shows above, the resistance used in this circuit is 100K OHM.

Step 3: Setup Solenoid

To lock and unlock the door, a 12V solenoid is used. The solenoid is a normally closed device, the latch unlocks when the solenoid is activated by a 12V power and vice versa. Arduino Uno can only output 5V and 3.3V which cannot activate the 12V solenoid. To solve this problem a 12V relay module shown is needed.

The figure above with a red board is the structure of the relay module (PID: 18405), DC+ and DC- connect to the 12VDC power. The pin IN controls the connection of the output pins (NO, COM, and NC), NO and COM connect together when pin IN receives 5V and vice versa. In this project, the pin IN is controlled by the Arduino UNO and the circuit shown above.

Step 4: Coding: Part 1

Step 5: Coding: Part 2

Step 6: Coding: Part 3

Step 7: Coding: Part 4

Step 8: Coding: Part 5

Step 9: Coding: Part 6

Step 10: Coding: Part 7

Step 11: Coding: Part 8

Step 12: Coding: Part 9

Step 13: Code Explanation

There are four states for the finite state machine which are Detecting State, Analysing State, Unlock State, and Reset State.

In the detect state, the machine keeps checking for the knock pattern from the user, this process loops forever until the machine receives a knock from the user or when the push button is pressed. If the push button is pressed, the machine jumps to the reset state. If the machine receives the knock pattern from the user, the machine jumps to analyzing state and starts analyzing the knock pattern. The analysis of the knock pattern will be discussed in the next section.

In analyzing state, if the knock pattern matches, it jumps to unlock state, starts the timer, and unlocks the solenoid. If the knock pattern does not match, the machine jumps back to the detect state. If the reset button is pressed, the analyzing process will be terminated and go to the reset state.

In unlock state, the machine keeps checking the timer. If the timer reaches the desired time(6 seconds in this project), the solenoid locks the latch again or vice versa. If the reset button is pressed, the machine will lock the solenoid, terminate the timer, and jump to the reset state.

In the reset state, if the reset button is held, the system records all the knocks patterns from the piezo sensor and the old password will be overridden by the new knocks patterns. If the reset button is held but the new password is not received, the password will not be updated. When the button is released, the machine jumps back to detect the state and waits for the knocking signal.

Step 14: Data Analysis

After the knock pattern is received, the system compares the knock by the user and the knock password. The data from the piezo sensor cannot be used to analyze since raw data has a lot of noise from the environment and different kinds of uncertainties.

We can easily visualize all the local maximums of the raw data, but the microcontroller cannot do it. Some manipulation applies to the data, first, we use the moving average to smooth the noise, then find the local maximums. After filtering the data, the data only shows the knocks as a pulse. By comparing the width of the pulse, we can identify the knock by the user and the password.

Step 15: Video Demonstration

Be the First to Share

    Recommendations

    • One Board Contest

      One Board Contest
    • Photography Challenge

      Photography Challenge
    • Raspberry Pi Contest

      Raspberry Pi Contest

    Comments