Raspberry Pi Pico

Raspberry Pi Pico and RFID based Door Lock Control System

Raspberry Pi Pico and RFID:

 

Raspberry Pi Pico and RFID based Door Lock Control System– In this tutorial, you will learn how to control an electronic door lock using Raspberry Pi Pico, a one-channel relay module, a 5v buzzer, and an MFRC522 RFID Reader module.

Just similar to an Arduino, ESP32, ESP8266, and STM32, Raspberry Pi Pico is also a controller board based on the RP2040 microcontroller, through the programming of which, you can control almost anything. And apart from this, you can also monitor different types of analog and digital sensors as well. In case you are using a Raspberry Pi Pico for the first time, I would definitely recommend you to read my “Getting started tutorial on Raspberry Pi Pico”. In this article, I have explained and attempted to shed light on almost everything in the article that a beginner must be acquainted with. In this getting started tutorial, I did 10 different beginners level projects.

allpcb circuit



I am sure almost 99.9% of people must be aware of the door locks, while, the remaining 0.1% are those people, who unluckily reside in such regions, where, I am afraid, people do not even know what actually the doors are?

Raspberry Pi Pico and RFID

Anyway, here is an ordinary door lock, which you can easily open or close with the help of a key.

Raspberry Pi Pico and RFID

Whereas, this is an Elock or Electronic Door lock, which you can simply control electronically. I am not using this electronic lock for the first time. I have used it on many occasions during my different projects. Most recently, I used the same particular electronic door lock with an ESP32 camera module, I have also used the same exact electronic door lock with the ESP8266 Wifi module. And, of course, needless to say, I have also used it with the Arduino.

Anyways, before I share with you the circuit diagram and code, first let’s watch the Raspberry Pi Pico and RFID based Door lock control system in action.


Raspberry Pi Pico and RFID

I have already powered up the entire system. Right now I have one RFID card and two RFID key chains. One of these key chains is authorized which I can use to open the electronic door lock, while the other one is unauthorized. When the unauthorized RFID card or keychain is used the buzzer is immediately turned ON.


Anyways, right now you can see, that when no authorized RFID card is used the Electronic door lock remains closed. Whereas when the authorized RFID card is used, the electronic door lock is opened.

Raspberry Pi Pico and RFID

You have obviously watched my video tutorial given at the end of this article, how easily we can control an electronic door lock using the Raspberry Pi Pico and RFID module. I am sure by now you might have got an idea of how does this system works. So, without any further delay, let’s get started!!!


Amazon Links:

Raspberry Pi Pico

12V Electronic Door Lock

5V Buzzer

MFRC522 RFID Module

12V One Channel Relay Module

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!



Raspberry Pi Pico and RFID, Circuit Diagram:

Raspberry Pi Pico and RFID

The SDA, SCK, MOSI, MISO, and RST pins of the MFRC522 RFID reader module are connected with the Raspberry Pi Pico GPIO pins 5, 6, 7, 4, and 3 respectively. And obviously the 3.3V and GND pins of the RFID module are connected with the Raspberry Pi Pico 3.3V and GND pins.

A one-channel relay module is controlled using the GP28 pin on the Raspberry Pi Pico. This is an SPDT-type relay. SPDT stands for single pole and double throw. The 12V wire to the Electronic door lock goes through this relay.

The 5V buzzer is controlled using the GP27 pin on the Raspberry Pi Pico. The 2n2222 NPN transistor and 10K resistor makes the driver circuit which is used to control the buzzer.


Raspberry Pi Pico and RFID, Python Programming:

Connect Raspberry Pi Pico with the Laptop.

Copy the code given below.

Mfrc522.py Code:

So, after copying the above code. Open the Thonny IDE and click on the new file. And paste this code. Save this code in the Raspberry Pi Pico with the name mfrc522.py.


Now, copy the code given below.

main.py code:

After you have copied the code, again go to the Thonny IDE and again click on the new file and paste this code. This time save this code in Raspberry Pi Pico with the name main.py

Now, finally you can click on the play button. You will be prompted, to place the card as you can see in the image given below. Swipe the RFID cards, tags, or key chains to find the UIDs.

My UIDs are:

4247b01e

a91bd36e

c645224b

Raspberry Pi Pico and RFID

You can see in the main.py code, I have used the same IDs to control the electronic door lock. You can find the identification numbers of your RFID cards using the same method and then update the main.py code accordingly. If you face any issues then watch my video tutorial given below.


Watch Video Tutorial:

 

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

4 Comments

  1. Hello Shahzada,
    1st: “very good job, thank you-!-”
    But when i place the chip too fast on the field. then break the program with a failure-message at line 31
    I fix this little bug in line 29: if stat == rc522.OK: —> if stat == rc522.OK and status == 0:
    …still have fun 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button