Dual-Mode Access Control System
Dual-Mode Access Control System with RFID and Keypad using Raspberry Pi Pico 2W
Author: BÎTLAN Adrian-Gabriel
GitHub Project Link: https://github.com/UPB-PMRust-Students/project-Bitlee1407
Description
This project implements a smart, dual-mode access control system using the Raspberry Pi Pico 2W. It allows entry through either RFID authentication or a PIN code entered via a keypad. A successful authentication unlocks a servo motor simulating door access, lights up a green LED, and plays a confirmation beep. Unsuccessful attempts trigger a red LED and a warning tone. The system is built entirely in Rust using the Embassy asynchronous framework, ensuring efficient multitasking and responsive hardware control.
Motivation
In an increasingly connected world, secure and flexible access control solutions are essential. Traditional keys are inconvenient and often insecure. RFID and PIN-based systems offer better control, and combining both in one embedded system offers even greater flexibility and security. By using the Rust programming language and the Embassy async framework, this project demonstrates modern embedded development with safe concurrency, targeting real-world problems. The use of both keypad and RFID readers adds redundancy and versatility, making the system ideal for shared workspaces, maker labs, or educational facilities.
Architecture
he heart of the system is the Raspberry Pi Pico 2W, which acts as the main controller, coordinating all connected components via its GPIO, I2C, SPI, and PWM interfaces.
The LCD1602 display with an I2C interface is responsible for showing status messages and prompts. It is connected to GPIO0 (SDA, Pin 1) and GPIO1 (SCL, Pin 2), powered by the Pico's 3.3V (Pin 36) and grounded at GND (Pin 38).
User input is captured through a 4x4 Matrix Keypad, which uses 8 GPIOs for scanning: GPIO2 to GPIO9 (Pins 4 to 11). The keypad is powered from the 3.3V rail and shares ground with the Pico.
The RC522 RFID Reader communicates via SPI. It connects as follows: SDA to GPIO16 (CS, Pin 21), SCK to GPIO18 (Pin 24), MOSI to GPIO19 (Pin 25), MISO to GPIO20 (Pin 26), RST to GPIO17 (Pin 22), and IRQ to GPIO22 (Pin 29). It draws power from the 3.3V (Pin 36) and is grounded to GND (Pin 38).
Two LEDs are used to visually indicate access status. The Green LED is connected to GPIO26 (Pin 31), and the Red LED is connected to GPIO27 (Pin 32), both with current-limiting resistors to ground.
A Servo Motor is responsible for physically simulating door lock movement. Its PWM signal is controlled via GPIO28 (Pin 34). The motor is powered directly from an external 5V battery through a shared NPN transistor switch, ensuring it doesn't overload the Pico.
A Buzzer is used for audio feedback and shares the same control transistor as the servo motor. The transistor's base is connected through a resistor to GPIO15 (Pin 20), its collector to the GND side of the motor and buzzer, and its emitter to GND. The positive side of the buzzer and servo is wired to the 5V external battery’s V+.
The external 5V battery is connected with its V+ feeding the servo and buzzer, and its GND tied to the Pico’s GND (Pin 38) to ensure a common reference.
Log
Week 5 - 11 May
Week 12 - 18 May
Week 19 - 25 May
Hardware
Detail in a few words the hardware used.
Schematics
Bill of Materials
Device | Usage | Price |
---|---|---|
Raspberry Pi Pico 2 W | The main board | 40 LEI |
MFRC522 RFID Reader | Reads RFID tags | 10 LEI |
LCD1602 with I2C | Displays prompts and status | 17 LEI |
4x4 Matrix Keypad | PIN input method | 7 LEI |
SG90 Servo Motor | Used to move the barrier | 12 LEI |
Buzzer Pasiv | Emits sound feedback | 2 LEI |
NPN Transistor (2N2222) | Controls servo & buzzer | 0.20 LEI |
GREEN Led | Indicates "Access Permitted." | 0.40 LEI |
RED Led | Indicates "Access Denied." | 0.40 LEI |
Breadboard | Put components on it | 30 LEI |
Female-to-Male Wires | For wiring | 3 LEI |
Male-to-Male Wires | For wiring | 30 LEI |
Software
Library | Description | Usage |
---|---|---|
embassy-executor | Async task executor for embedded systems | Runs concurrent tasks like keypad scanning, RFID polling, and feedback control |
embassy-rp | Hardware abstraction layer for the RP2040 | Interfaces with peripherals like SPI (RFID), I2C (LCD), GPIO (LEDs), and PWM (Servo) |
embassy-time | Timers and delays for async code | Implements non-blocking delays and timeout logic |
embassy-sync | Async synchronization primitives | Coordinates shared access to peripherals across tasks |
embedded-hal | Unified hardware interface traits | Defines abstract traits for embedded drivers |
embedded-hal-async | Async traits for embedded-hal | Enables async I2C, SPI, and GPIO interfaces for peripheral drivers |
defmt | Lightweight logging for embedded systems | Used to debug the system without printing over serial |
defmt-rtt | Logging backend via RTT | Sends logs through debug probes to the host for analysis |