A personal project: an electronic door-lock controller for the STM32F103C8T6 ("Blue Pill") supporting three independent unlock methods — keypad password, RFID card, and fingerprint — with an LCD UI, buzzer/LED feedback, and persistent storage in an external I²C EEPROM.
Note: built and tested on a physical demo model (mock door driven by a servo), not a production lock. See the Disclaimer below.
- Keypad password: 4-digit unlock; change password at runtime (saved to EEPROM).
- Brute-force lockout: 3 wrong attempts → 30-second lockout with on-screen countdown.
- RFID (RC522): tap-to-unlock; add / remove cards in admin mode.
- Fingerprint (AS608): 2-pass enrollment, 1:N search unlock, delete by ID (up to 127 templates).
- Admin mode: password-protected enrollment of new cards / fingerprints.
- Servo lock: PWM-driven lock/unlock, auto-relock after 3 s.
- Feedback: 16×2 I²C LCD status screens, status LED, buzzer patterns.
- Debug log: human-readable trace over USART1 @ 57600 baud.
- Persistence: password, enrolled cards, and next-fingerprint-ID survive power loss (I²C EEPROM).
| Module | Interface | STM32 pins |
|---|---|---|
| AS608 fingerprint | USART2 | PA2 (TX), PA3 (RX) |
| RC522 RFID | SPI1 | PA5 (SCK), PA6 (MISO), PA7 (MOSI), PA4 (SS), PA8 (RST) |
| LCD 1602 (PCF8574) | I²C1 | PB8 (SCL), PB9 (SDA) |
| Servo (lock) | TIM1_CH2 PWM | PA9 |
| Buzzer | GPIO | PB3 |
| Keypad 4×4 — rows | GPIO | PB12, PB13, PB14, PB15 |
| Keypad 4×4 — cols | GPIO | PA10, PA11, PA12, PA15 |
| Debug UART | USART1 | PB6 (TX), PB7 (RX) |
| EEPROM | I²C1 | shared with LCD |
Servo timing: TIM1 @ 20 ms period (prescaler 71), lock pulse 833,
unlock pulse 1833, door-open time 3000 ms — see Core/Inc/door_control.h.
| Value | Where | |
|---|---|---|
| User password | 6666 |
PASS_DEFAULT in Core/Inc/password.h |
| Admin password | 9999 |
PASS_ADMIN in Core/Inc/password.h |
Change both before using this for anything real (see Disclaimer). The user password can also be changed at runtime from the keypad; the admin password is compile-time only.
This is an STM32CubeIDE project (.ioc + .cproject included).
- Open STM32CubeIDE → File → Open Projects from File System → select this folder.
- Build (Project → Build, or
Ctrl+B). - Flash to the board via ST-Link (Run / Debug).
Regenerating from the .ioc in CubeMX will re-create the HAL init code if you
change the pin configuration.
To watch the debug log, connect a USB-TTL adapter to PB6/PB7 and open a serial terminal at 57600 baud, 8-N-1.
- Idle: tap an enrolled card, place an enrolled finger, or type the 4-digit password + confirm to unlock.
- Admin menu (from keypad): enroll/remove card, enroll/delete fingerprint, change password — each guarded by the admin password.
- Fingerprint delete: enter the 3-digit ID (e.g. ID 5 → type
005).
Core/
Inc/ module headers (pin maps, constants)
Src/ drivers + app logic
main.c init + super-loop
app_tasks.c LED / RFID / fingerprint polling tasks
password.c keypad UI, password, admin flows
fingerprint.c AS608 packet protocol over USART2
rc522.c RFID over SPI1
lcd_i2c.c 1602 LCD over I²C
door_control.c servo lock + buzzer + card store
eeprom.c I²C EEPROM read/write
Drivers/ STM32 HAL + CMSIS
This is a personal project. It runs on my specific demo hardware (STM32F103C8T6 + AS608 + RC522 + 4×4 keypad + 1602 I²C LCD + servo), but it has not been security-audited or tested beyond my own model.
- Do not use this as-is to protect anything you actually care about.
- Change
PASS_DEFAULTandPASS_ADMINinCore/Inc/password.hbefore flashing. - Different modules or wiring may need pin/timing changes — check the
.iocfile and the per-module headers inCore/Inc/.
Use at your own risk.