Smart Lockbox
A Rust-based electronic lockbox with keypad PIN access, servo lock control, local feedback, and ESP32 networking for logs/admin reset.
Author: Sergiu Lefter
GitHub Project Link: fils-project-2026-sergiulefter
Description
This project is a smart lockbox controlled by an STM32 Nucleo board. The user enters a PIN on a 3x4 keypad. If the PIN is correct, an SG90 servo unlocks the box. If it is wrong, access is denied and a passive buzzer gives warning feedback.
I also use a mechanical endstop to detect when the lid is closed, so the lock can return automatically to the locked position. For the extended version, I added an ESP32 for network logging and a possible admin reset flow for the PIN.
Motivation
I chose this project because it is practical and also a good embedded Rust challenge. It combines hardware and software in one system: keypad input, control logic, servo actuation, sensor feedback, and communication. I also wanted to build something physical that I can test and improve step by step.
Architecture
Main architecture components:
- Input: 3x4 keypad, admin button, mechanical endstop.
- Main control: STM32 Nucleo (rental) running the lock logic and state machine.
- Output: SG90 servo for lock movement, LCD1602 (I2C) for messages, passive buzzer for alerts.
- Network side: ESP32 DevKitC for logging and possible admin reset/dashboard.
- Wiring setup: STM32 connects through a small interface protoboard (female headers), then to the main protoboard where modules are connected.
How components connect:
- Keypad, button, and endstop send inputs to the STM32.
- STM32 controls the servo, buzzer, and LCD.
- ESP32 communicates with STM32 over serial/UART for logging/admin features.
- Components are assembled on protoboard/PCB prototyping boards using silicone stranded wires.
Software State Machine
The software is organized as a state machine with the following states:
LOCKEDENTERING_PINUNLOCKEDWAIT_FOR_CLOSEADMIN_MODEALARM
Architecture Diagram
Input Block (3x4 Keypad, Admin Button, Mechanical Endstop)
|
| GPIO
v
STM32 Nucleo (Main Control: PIN + State Machine)
|
| via small interface protoboard (female headers)
v
Main Protoboard (distribution for components)
| | |
| I2C | PWM | GPIO/PWM
v v v
LCD1602 + I2C SG90 Servo Passive Buzzer
STM32 Nucleo
|
| UART / Serial
v
ESP32 DevKitC (Logging + optional Admin PIN reset)
Log
Week 4-5
Researched smart lockbox implementations and decided on the final project direction. Chose the main architecture around STM32 + keypad + servo and started the documentation page.
Week 6-7
Updated the hardware plan and replaced several components: breadboard with protoboard, 4x4 keypad with 3x4 keypad, reed switch with mechanical endstop, and active buzzer with passive buzzer. Ordered all required parts and checked compatibility.
Week 8
Defined the interface-board approach to avoid soldering on the rental STM32 board (female header bridge to the main protoboard). Added ESP32 networking scope for event logging and possible admin PIN reset flow.
Hardware
The lockbox prototype uses a mixed setup with reusable university hardware and purchased modules. The STM32 board is provided by the university as free rental (must be returned after project completion). The rest of the circuit is assembled using protoboard/PCB prototyping boards and silicone stranded wires.
Schematics
TODO: add KiCAD (or similar) schematic SVG in this folder and reference it here.
Bill of Materials
| Device | Usage | Price |
|---|---|---|
| STM32 development board (university borrow) | Main controller board for firmware development and peripheral control | 0 RON (borrowed) |
| Placa dezvoltare ESP32-DevKitC, ESP32-WROOM-32D, 38P | Networking/logging module and potential admin dashboard support | 42.56 RON |
| Placa PCB prototipare o fata 5x7 | Small interface protoboard used between STM32 and the main wiring board | 2.95 RON |
| Placa PCB prototipare fata dubla 7x9cm | Main (big) protoboard used for the rest of the components | 5.76 RON |
| Bara 40 pini 2.54 tata | Header pins for module interconnection | 2.06 RON |
| Bara pini 40p mama 2.54mm, pin rotund, segmentabil x3 | Female headers for detachable wiring/interfaces | 7.08 RON (total) |
| Tastatura numerica 4x3, 12 butoane | PIN entry keypad (3x4) | 18.76 RON |
| Buton 12x12x7.3 | Local control/input button | 1.33 RON |
| Endstop mecanic SS-5GL2 | Position sensing (replaces reed switch) | 5.23 RON |
| Servomotor SG90, 180 grade, cu limitator | Mechanical lock actuation | 9.49 RON |
| Buzzer pasiv 5V | Audio feedback for success/error events | 1.45 RON |
| LCD 1602 | Status display for prompts and lock messages | 11.18 RON |
| Modul interfata I2C LCD 1602/2004 | I2C adapter for LCD communication | 5.11 RON |
| Tranzistor NPN BC547 TO-92 | Driver/transistor stage in auxiliary control circuits | 1.21 RON |
Software
| Library/Framework | Description | Usage |
|---|---|---|
| Embassy | Async embedded Rust framework | Main embedded architecture and task scheduling |
| embassy-stm32 | STM32 peripheral support for Embassy | GPIO/I2C/PWM integration on STM32 |
| embassy-executor | Async executor | Runs concurrent embedded tasks |
| embassy-time | Timing, delays, and timeouts | Debounce logic, lock timers, alarm timing |
| embedded-hal | Hardware abstraction traits | Portable driver interfaces |
| embedded-hal-async | Async HAL traits | Async peripheral operations |
| defmt | Lightweight logging for embedded Rust | Structured firmware logs during development |
| defmt-rtt | RTT transport for defmt | Real-time debug output |
| panic-probe | Panic reporting | Panic handling during debugging |
| heapless | no_std data structures | Fixed-capacity buffers/queues for embedded-safe logic |
| esp-idf-svc | ESP32 service layer in Rust | Networking/logging and admin-side integration |