Skip to main content
Version: FILS English

Dual-Mode Access Control System

Dual-Mode Access Control System with RFID and Keypad using Raspberry Pi Pico 2W

info

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

KiCadScheme

Bill of Materials

DeviceUsagePrice
Raspberry Pi Pico 2 WThe main board40 LEI
MFRC522 RFID ReaderReads RFID tags10 LEI
LCD1602 with I2CDisplays prompts and status17 LEI
4x4 Matrix KeypadPIN input method7 LEI
SG90 Servo MotorUsed to move the barrier12 LEI
Buzzer PasivEmits sound feedback2 LEI
NPN Transistor (2N2222)Controls servo & buzzer0.20 LEI
GREEN LedIndicates "Access Permitted."0.40 LEI
RED LedIndicates "Access Denied."0.40 LEI
BreadboardPut components on it30 LEI
Female-to-Male WiresFor wiring3 LEI
Male-to-Male WiresFor wiring30 LEI

Software

LibraryDescriptionUsage
embassy-executorAsync task executor for embedded systemsRuns concurrent tasks like keypad scanning, RFID polling, and feedback control
embassy-rpHardware abstraction layer for the RP2040Interfaces with peripherals like SPI (RFID), I2C (LCD), GPIO (LEDs), and PWM (Servo)
embassy-timeTimers and delays for async codeImplements non-blocking delays and timeout logic
embassy-syncAsync synchronization primitivesCoordinates shared access to peripherals across tasks
embedded-halUnified hardware interface traitsDefines abstract traits for embedded drivers
embedded-hal-asyncAsync traits for embedded-halEnables async I2C, SPI, and GPIO interfaces for peripheral drivers
defmtLightweight logging for embedded systemsUsed to debug the system without printing over serial
defmt-rttLogging backend via RTTSends logs through debug probes to the host for analysis
  1. link
  2. link ...