IoT Door Lock with QR scan and DB - Labs Residency Project

Hello everyone!
My name is Lambros , and I joined Balena two weeks ago.
The goal of my project is to use the Raspberry Pi to make an automated door.
I have no technical background, so I tried to come up with some ideas on how an employee may gain access to the office without having to manually create and register an account with the door control application.

The following was my first simplified approach.
1.When an employee approaches the door, his phone automatically connects to the office’s Wi-Fi.
2.Every “some” seconds, Raspberry checks local Wi-Fi devices.
3.If the Mac-address of the registered cellphone is found in the Local Wi-Fi list, Raspberry sends a signal to open the door.

There are a number of pain points to the current approach:
1.Employees must register their Mac addresses with an online document before visiting the workplace.
2. Numerus concerns about security.
3. The employer will still be connected to the office’s Wi-Fi, and Raspberry will continue to send out signal to open the door.

I’m thinking of choosing this method after considering the pain points. The steps are as follows:
1.When an employee approaches the door, his cellphone automatically connects to the office’s wireless network.
2. Employee accesses a local page by typing Raspberry local IP into his web browser.
3. Enter the employee’s credentials into the local page (Raspberry connected to an API with the company’s employee credentials, Google credentials?)
4. When the employee presses the open button on the local page , the door opens.

The most important issues to consider.
1.It will take too long to enter the office.
2. It will be difficult to type while carrying bags and other items.

I’ll be using the following hardware:
1.A raspberry pie 4
2.A solenoid lock
3.A relay module
4. 12V 3A power supply
5. 12 V to 5V converter

I’m starting with Python( baby steps) and would like to balenify it with Docker.?
I welcome suggestions and ideas for how to make this project work :slight_smile:



I added a pi camera for QR code scanning to solve a part of the “how to open the door quickly problem.”
My first step was to scan a QR code (Hello World) to unlock the door, which was then locked after 5 seconds.

import cv2
import RPi.GPIO as GPIO
import time

relay = 17;

GPIO.setup(relay , GPIO.OUT)
GPIO.output(relay , 0)
GPIO.output(relay , 1)

# set up camera object
cap = cv2.VideoCapture(0)

# QR code detection object
detector = cv2.QRCodeDetector()

doorUnlock= False

while (True):    
    # get the image
    _, img =
    # get bounding box coords and data
    data, bbox, _ = detector.detectAndDecode(img)
    # if there is a bounding box, draw one, along with the data
    if(bbox is not None):
        for i in range(len(bbox)):
            cv2.line(img, tuple(bbox[i][0]), tuple(bbox[(i+1) % len(bbox)][0]), color=(255,
                     0, 255), thickness=2)
        cv2.putText(img, data, (int(bbox[0][0][0]), int(bbox[0][0][1]) - 10), cv2.FONT_HERSHEY_SIMPLEX,
                    0.5, (0, 255, 0), 2)
        if data:
            print("data found: ", data)
            if data == 'Hello World':
                print('Access Granted')
                GPIO.output(17 , 0)
                prevTime = time.time()
                doorUnlock = True
                print('Door Open ')
                print('Access Denied')
    if doorUnlock == True and time.time() - prevTime > 5:    
        doorUnlock = False
        GPIO.output(17 , 1)
        print('Door Locked ')            
    cv2.imshow("code detector", img)
    if(cv2.waitKey(1) == ord("q")):

The following step would be to create a local page with Flask (python) to register the users.(

The final step would be to automatically generate and send a new QR code to each user’s email based on NAME SURNAME RANDOMNUMBER every day, as well as keep a log of who entered the building and when.

As a proof of concept, I’m doing it with one raspberry for one door.
Any suggestions would be greatly appreciated. :slight_smile:

awesome! this is what our product doing~~~ :smile:

It’s a IoT door lock with QR scan as well. We use raspberry zero as the main controller.

I finished the project.

The steps would be as follows:

Code : GitHub - LPapapo/IoTDoorLockManagement
Next step to Balenafy it!!

1 Like

cool stuff!

Did you try this in a real door @LPapapo ? :slight_smile:

No, I didn’t try it in a real door. Whether or not the project works in a real door is more a matter of finding the right solenoid lock that can fit in the right door.
Improvements can be made (many) . Perhaps an IR sensor that detects whether the door is still open so that the solenoid lock is not locked while the door is not closed but ye ,it will work in a real door . :slight_smile: @mpous

1 Like

Nice! thank you for the clarification @LPapapo :slight_smile: