Introduction: DIY Mask/QR Code Recognition Smart Access Device W Raspberry Pi

About: Elecrow is an open hardware facilitation company based in Shenzhen. To make your making and innovation easier, we offer various development platforms, modules, tools, electronics components, and other open-sou…

Yo, my hood's been hit by another wave of COVID-19 and some of my coworkers are showing symptoms of a second infection, yet they still refuse to mask up! To remind them to wear their masks and to keep myself healthy, I decided to make a punch-clock-like device that can detect whether my colleagues have properly masked up, check their temps, and even scan their health codes. To make it look cooler, I used OpenCV and Python to recognize and display different images of masked and unmasked faces, and slapped on an infrared thermal imaging module to display body temps. I'm pretty sure my coworkers will think it's dope when they see it and be more willing to cooperate with the checks. This project is not only gonna keep us healthy during the pandemic, but also help us understand target recognition and HTTPS protocol.

Supplies

Raspberry Pi 4B x1 ---> I will use it as my main control board. It has a powerful configuration, can run OpenCV, and its performance is much smoother than the 3B+ (before this, I tried to run OpenCV on the 3B+, but the image was very slow).

7 inch Screen x1 ---> "This screen fits perfectly with the size of my case, and the image is very clear. It is also touch-enabled, although I haven't used the touch function yet. During my testing, I found that the touch screen is very responsive, which surprised me.

Infrared module x1 ---> "I will use it to help me determine whether a phone is approaching after the prompt 'Please show the health code'.

Camera x2 --->Camera 1 is used for recognizing faces and masks, while Camera 2 is used for recognizing health codes. However, I recently discovered that Elecrow has launched a QR code recognition module. This means that after completing this small project, I can eliminate one camera and use the QR code recognition module to replace it.

Device casing x1 ---> The case is not custom-made, so everyone can design it according to their own preferences or use a similar case. Implementing the functionality is our primary goal and the most enjoyable part of the project.

MLX90640 Thermal imaging module x1 ---> I will use this module to implement thermal imaging functionality, and it can help me measure the body temperature of the user. It looks very cool.

Buzzer module x1 --> It will make a 'beep' sound after taking a photo of the health code.

MP3 module & Speaker x1 ---> It will play the voice prompt that I have pre-recorded and stored in the SD card, to guide the user on what to do.

SD card x2 ---> One is used to run the Raspberry Pi system, while the other is used to store MP3 files.

Battery x1 ---> I plan to use a battery to power my device, and I must strictly follow the power requirements of the Raspberry Pi, which is 5V and 3A.

Switch x1 ---> A switch that helps me control the power on and off.

DuPont wires xN --->The tool that helps me connect modules together.

Step 1: Make the Case

To speed up the process of making my device, I bought a case online that was close to what I needed. I then modified it to fit my requirements better. Here's what I did:

First, I cut a small hole in the case to make sure the screen's wires wouldn't be blocked. I smoothed out the edges with a file.

Next, I noticed that the case didn't close properly when I put in the Raspberry Pi. So I had to cut off a few pillars on the back cover of the case. After that, I could easily close the case even with the Raspberry Pi inside.

Lastly, I made a hole on the case bigger so that I could fit my switch button.

Step 2: Make and Connect the Switch

When I was planning it out, I totally forgot about the on/off switch. It wasn't until I was halfway through making it that I suddenly remembered. I realized that if I didn't include a switch, it would be a real pain to turn the thing on and off - I'd have to keep opening up the box and plugging/unplugging the power cord. But if I put in a switch, it would be way easier to control the power.

Step 3: Connect All Modules Together

After preparing the case, you can start connecting all the modules together. This step is crucial and requires careful attention. Make sure you don't connect the wires incorrectly, especially the positive and negative poles. If there is a short circuit, it may damage the modules or even your Raspberry Pi!

In addition, there are two cameras that you need to connect to the Raspberry Pi. One is a QR code camera that can be plugged into any USB port on the Pi, and the other is a mask recognition camera that should be connected to the Pi's default CAMERA interface.

Here is the wiring diagram that I prepared. You can follow this diagram to connect the modules. Please make sure you don't connect them incorrectly.

Step 4: Fixing and Assembly

First, let's use some hot glue to stick the screen and QR code camera onto the front of the case. This will make things easier when we're putting everything together later. Then we can fix all the other parts onto the back of the case. I decided where to put them based on the case I'm using, but you can arrange them however you like as long as everything can connect properly and the case closes up completely.

Step 5: Wrtie the Image

I've finished the hardware part, and now in this step, I need to download an image onto my computer. Setting up the environment is a bit complicated and if I make a mistake, it could mess up the software and I'd have to start all over again, which takes a lot of time. That's why I highly recommend using the image I'm providing.

Before I can burn the image, I need to download and install a software called "Win32 Disk Imager," which will help me burn the image onto an SD card. After I've installed the software, I'll open it, find the image I'm using, choose the SD card, and click "Write" to burn the image.

Once the burning process is complete, I'll insert the SD card into the Raspberry Pi, and then it's ready to be turned on!

Step 6: Set Up WIFI

because my program requires internet access to upload the health code photo taken to a cloud-based API via HTTPS, wait for the API to recognize the code and return the result, and then display the result accordingly.

To set up Wi-Fi, first execute the command:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Locate the following code:

network={

ssid="YOUR_WIFI_NETWORK_NAME"

psk="YOUR_WIFI_PASSWORD"

}

Replace "YOUR_WIFI_NETWORK_NAME" and "YOUR_WIFI_PASSWORD" with your own Wi-Fi network name and password.

After modifying the Wi-Fi network and password, save the file and exit the editor, then restart. The Raspberry Pi will automatically connect to your Wi-Fi network.

Step 7: Power It Up !

I have placed the program in the directory "Mask_nd_Temp/New_jkm" on the desktop. If you don't want the program to automatically run at startup, you can go to the "/etc/rc.local" file.

Locate the following code:

sudo bash /home/njl/runapp.sh

put a "#" in front of it, and then save the file. This will disable the automatic startup.


After completing all of the above steps, I can see the same effect as shown in the video. Isn't it amazing? And it only requires a Raspberry Pi 4B to achieve such a cool function, which impressed my colleagues and made me very happy. It also helps remind my colleagues to wear masks and reduce the risk of infection.

Finally, I wish all my friends who have read this good health and happiness every day!