Build Your Own Qr Code Lock And Manage It Through Our Apps
About the project
Our goal is to replace a regular key with a system that will open a Lock by scanning a QR Code generated on the smartphone. The entire project consists of 3 open source repos; mobile app, website and Scanner on Raspberry (ESP32 in the future)
Project info
Difficulty: Moderate
Platforms: Android, Everything ESP, Honeywell, Raspberry Pi, Python
Estimated time: 3 hours
License: MIT license (MIT)
Items used in this project
Hardware components
Software apps and online services
Story
About us:
We are a group of young students from Poland. We are creating a new project during our internship which will attract students, engineers, and technology enthusiasts.
About project:
Our goal is to replace a regular key with a system that will open a lock by reading a QR code from our smartphone. The system is based on Raspberry, but we would like to create it on a budget i.e. ESP32, so every one of you could recreate it in the garage.
How does it work?
• Generate a QR code in the mobile or website app
• Scan QR with a code reader
• The gate opens for 5 seconds
• The device sends an Event log to the website
Tutorial:
*YouTube
- ----------On your desktop----------
- Download balenaEtcher and the latest raspbian OS (without desktop)
- Flash OS on SD card using balena
- After installation skip the validation process
- Flash completed
- -----------Raspberry Configuration------------
- Now plug everything up to the raspberry pi: SD card, module & sensor, ethernet, keyboard, QR scanner, hdmi, and power cable.
- * If you are not sure about pins for the motion sensor and module (cause you are using a different raspberry) search the internet for the "pinout" of your device model.
- When everything is plugged the raspberry will turn on automatically.
- -----------System setup--------------
- After first boot, choose your language and keyboard layout
- Create a user and type a password
- ------------Type Following Commands-----------------
- sudo su
- passwd root (the system will ask you for a password)
- update repositories using: apt update
- Install dependencies using: apt install python3 python3-pip socat git mosquitto (the system may ask you for more updates. Type Y)
- Install essential python modules: pip3 install rpi.gpio pyserial paho-mqtt
- Copy our repository: git clone https://github.com/theiotproject/key-scanner
- Enter cloned folder using: cd key-scanner
- Install current release using: dpkg -i KeyScanner (press tab to autofill and enter)
- Enable scanner service to start on boot: systemctl enable scanner
- Start the service: systemctl start scanner
- Wait 20 seconds before the next step in order to properly start the app.
- --------KeyManager--------
- Click here to create an account on our website.
- After that read all the pop-ups to understand the logic of the keys and gates.
- Create gate
- Fill the gaps: Temporary, the serial number is a random string data type.
- After that get on with the key creator.
- Check the boxes and click create.
- ----------Mobile app----------
- Download the proper asset on your android phone and install it.
- After installation open the app (search for Virtual Key) and log in
- The next step is very important. In the app find your gate (created in the website) and slide to right in order to generate QR code.
- onfiguration code to scan.
- Wait 20 seconds before the next step in order to configure everything well.
- ----------Back to console----------
- Restart the scanner to apply configured data: systemctl restart scanner
- You can check if the data got applied successfully using: cat /etc/KeyScannerconf/magic.guid
- ----------Last touch----------
- Open the Virtual Key app on your phone again and look for the gate (on the bottom you will find easy navigator to move between interfaces). Once you click it the QR code will generate automatically and will be ready to scan!
- Scan this code and wait till the relay on raspberry will turn on (red diode). It's proof that everything is working well.
- -------Additional Command---------
- cat /var/log/syslog (it will show you the latest usage of lock: OPEN/LOCK)
Security:
We managed it using SHA 256 cryptography. Check this schema to understand:
1. First part:
ID - key usage
VF & VT - valid from & valid to
L - locks matching with key
2. Second part
Combine the first part with secret code - the unique 16 signs every user (generating via website)
3. Third part
Then we want this „freak” to short using sha-256.
4. Generate QR
Leave your feedback...