Skip to content

Commit 08de223

Browse files
authored
Project/sergiu.lefter (#1427)
* Add initial documentation for Smart Lockbox project * Add architecture diagram for Smart Lockbox project * Refactor protoboard setup in project documentation: updated wiring descriptions, clarified component assembly on two 7x9 protoboards, and revised bill of materials for accuracy. * Added images and update documentation * Fixed image format to be webp instead of jpg * Renamed images with lowercase
1 parent 93b8cef commit 08de223

10 files changed

Lines changed: 55 additions & 51 deletions
58.5 KB
Loading

website/versioned_docs/version-fils_en/project/2026/sergiu.lefter/index.md

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -15,63 +15,48 @@ A Rust-based electronic lockbox with keypad PIN access, servo lock control, loca
1515
This project is a smart lockbox controlled by an STM32 Nucleo board.
1616
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.
1717

18-
I also use a mechanical endstop to detect when the lid is closed, so the lock can return automatically to the locked position.
19-
For the extended version, I added an ESP32 for network logging and a possible admin reset flow for the PIN.
18+
For the extended version, I added an ESP32 for network logging, remote commands, and a local admin panel for PIN management.
2019

2120
## Motivation
2221

2322
I chose this project because it is practical and also a good embedded Rust challenge.
24-
It combines hardware and software in one system: keypad input, control logic, servo actuation, sensor feedback, and communication.
23+
It combines hardware and software in one system: keypad input, control logic, servo actuation, user feedback, and communication.
2524
I also wanted to build something physical that I can test and improve step by step.
2625

2726
## Architecture
2827

2928
Main architecture components:
30-
- Input: 3x4 keypad, admin button, mechanical endstop.
31-
- Main control: STM32 Nucleo (rental) running the lock logic and state machine.
32-
- Output: SG90 servo for lock movement, LCD1602 (I2C) for messages, passive buzzer for alerts.
33-
- Network side: ESP32 DevKitC for logging and possible admin reset/dashboard.
34-
- Wiring setup: STM32 connects through a 7x9 interface protoboard (female headers), then to a second 7x9 main protoboard where modules are connected.
35-
36-
How components connect:
37-
- Keypad, button, and endstop send inputs to the STM32.
38-
- STM32 controls the servo, buzzer, and LCD.
39-
- ESP32 communicates with STM32 over serial/UART for logging/admin features.
40-
- Components are assembled on two 7x9 protoboard/PCB prototyping boards using silicone stranded wires.
29+
- Input: 3x4 keypad and one admin button.
30+
- Main controller: STM32 Nucleo.
31+
- Output: SG90 servo, LCD1602 with I2C backpack, passive buzzer.
32+
- Network side: ESP32 DevKitC with a small web admin panel.
33+
- Assembly: one 7x9 interface protoboard for the STM32 connection and one 7x9 main protoboard for the rest of the circuit.
34+
35+
How the system works:
36+
- The keypad sends the PIN to the STM32.
37+
- The STM32 checks the PIN, controls the servo, updates the LCD, and triggers the buzzer.
38+
- The admin button is used for local override/reset actions.
39+
- The ESP32 talks to the STM32 over UART and provides logging plus a simple Wi-Fi admin panel.
40+
- I used two protoboards so I would not solder directly on the rental STM32 board.
4141

4242
### Software State Machine
4343

44-
The software is organized as a state machine with the following states:
45-
- `LOCKED`
46-
- `ENTERING_PIN`
47-
- `UNLOCKED`
48-
- `WAIT_FOR_CLOSE`
49-
- `ADMIN_MODE`
50-
- `ALARM`
51-
52-
### Architecture Diagram
53-
54-
```text
55-
Input Block (3x4 Keypad, Admin Button, Mechanical Endstop)
56-
|
57-
| GPIO
58-
v
59-
STM32 Nucleo (Main Control: PIN + State Machine)
60-
|
61-
| via 7x9 interface protoboard (female headers)
62-
v
63-
Main 7x9 Protoboard (distribution for components)
64-
| | |
65-
| I2C | PWM | GPIO/PWM
66-
v v v
67-
LCD1602 + I2C SG90 Servo Passive Buzzer
68-
69-
STM32 Nucleo
70-
|
71-
| UART / Serial
72-
v
73-
ESP32 DevKitC (Logging + optional Admin PIN reset)
74-
```
44+
The software is organized around a small access-control state machine:
45+
- `PIN_SETUP`: active when no valid PIN is stored yet. The box stays accessible and the user must define a new PIN.
46+
- `LOCKED`: normal idle state after a PIN exists. The system waits for keypad input and compares it with the saved code.
47+
- `UNLOCKED`: entered after a valid PIN or an admin override. In this state the servo opens the mechanism and the UI shows that access is granted.
48+
49+
The implementation is split into two software parts:
50+
- STM32 firmware written in Rust with Embassy. This side handles keypad scanning, servo control, LCD updates, buzzer patterns, UART communication, and flash-backed PIN persistence.
51+
- ESP32 admin-panel firmware written as an Arduino sketch. This side creates a local Wi-Fi access point, serves the web panel, forwards commands over UART, and keeps temporary logs in RAM.
52+
53+
For hardware bring-up and debugging, the STM32 firmware also includes multiple `FirmwareMode` test modes:
54+
- `BuzzerTest`
55+
- `ServoTest`
56+
- `KeypadTest`
57+
- `AdminButtonTest`
58+
- `UartTest`
59+
- `FullApp`
7560

7661
## Log
7762

@@ -81,10 +66,31 @@ ESP32 DevKitC (Logging + optional Admin PIN reset)
8166
Researched smart lockbox implementations and decided on the final project direction. Chose the main architecture around STM32 + keypad + servo and started the documentation page.
8267

8368
### Week 6-7
84-
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.
69+
Updated the hardware plan and replaced several components: breadboard with protoboard, 4x4 keypad with 3x4 keypad, and active buzzer with passive buzzer. Ordered all required parts and checked compatibility.
8570

8671
### Week 8
87-
Defined the interface-board approach to avoid soldering on the rental STM32 board (female header bridge through a dedicated 7x9 protoboard). Added ESP32 networking scope for event logging and possible admin PIN reset flow.
72+
Defined the interface-board approach to avoid soldering on the rental STM32 board (female header bridge through a dedicated 7x9 protoboard). Added ESP32 networking scope for event logging and a local admin control flow.
73+
74+
### Week 9-10
75+
Started putting together the hardware and moving from planning to real assembly. A big part of this stage was debugging early hardware issues, especially the LCD, which initially powered on but did not show text correctly.
76+
77+
![LCD not working yet](./lcd_not_working.webp)
78+
79+
### Week 11-12
80+
Continued debugging all hardware components until they became reliable. I discovered that I had badly soldered the I2C backpack onto the LCD, so I had to buy a new one and solder it again correctly on the second attempt. After that, I got almost all major components working on a breadboard, with the ESP being the first one I brought up successfully.
81+
82+
![LCD working after fixing the backpack](./lcd_working.webp)
83+
![Second LCD working test](./lcd_working_2.webp)
84+
![ESP32 working on the breadboard](./esp32_working.webp)
85+
86+
### Week 13-14
87+
Implemented software testing modes through `FirmwareMode` and also built the ESP32 web admin panel. During final hardware assembly I badly soldered one keypad pin and burned the keypad, so I had to rethink the keypad concept and adapt the layout creatively using symbols instead of the original numeric-only interaction.
88+
89+
![Locked mode with entered code](./locked_mode_entered_code.webp)
90+
![Locked mode after wrong code](./locked_mode_code_wrong.webp)
91+
![Unlock with admin button](./unlock_with_admin_button.webp)
92+
![Broken keypad pin after soldering](./keypad_broken_pin.webp)
93+
![Restructured keypad with symbols](./keypad_restructured_with_symbols.webp)
8894

8995
## Hardware
9096

@@ -111,7 +117,6 @@ The rest of the circuit is assembled using two 7x9 protoboard/PCB prototyping bo
111117
| [Header de Pini Mama 6p 2.54 mm](https://www.optimusdigital.ro/ro/componente-electronice-headere-de-pini/4156-header-de-pini-mama-6p-254-mm.html?search_query=0104210000035032&results=1) | Female headers for detachable wiring/interfaces | 0,49 RON |
112118
| [Tastatura numerica 4x3, 12 butoane](https://sigmanortec.ro/tastatura-numerica-4x3-12-butoane) | PIN entry keypad (3x4) | 18.76 RON |
113119
| [Buton 12x12x7.3](https://sigmanortec.ro/Buton-12x12x7-3-p160373654) | Local control/input button | 1.33 RON |
114-
| [Endstop mecanic SS-5GL2](https://sigmanortec.ro/Endstop-mecanic-SS-5GL2-p136284192) | Position sensing (replaces reed switch) | 5.23 RON |
115120
| [Servomotor SG90, 180 grade, cu limitator](https://sigmanortec.ro/Servomotor-SG90-limit-switch-p141662062) | Mechanical lock actuation | 9.49 RON |
116121
| [Buzzer pasiv 5V](https://sigmanortec.ro/Buzzer-pasiv-5v-p172425809) | Audio feedback for success/error events | 1.45 RON |
117122
| [LCD 1602](https://sigmanortec.ro/LCD-1602-p125700685) | Status display for prompts and lock messages | 11.18 RON |
@@ -125,14 +130,13 @@ The rest of the circuit is assembled using two 7x9 protoboard/PCB prototyping bo
125130
| [Embassy](https://embassy.dev/) | Async embedded Rust framework | Main embedded architecture and task scheduling |
126131
| [embassy-stm32](https://docs.embassy.dev/embassy-stm32/) | STM32 peripheral support for Embassy | GPIO/I2C/PWM integration on STM32 |
127132
| [embassy-executor](https://docs.embassy.dev/embassy-executor/) | Async executor | Runs concurrent embedded tasks |
128-
| [embassy-time](https://docs.embassy.dev/embassy-time/) | Timing, delays, and timeouts | Debounce logic, lock timers, alarm timing |
133+
| [embassy-time](https://docs.embassy.dev/embassy-time/) | Timing, delays, and timeouts | Debounce logic, unlock timers, and UI timing |
134+
| [embassy-sync](https://docs.embassy.dev/embassy-sync/) | Synchronization primitives for Embassy | Background buzzer event channel between tasks |
129135
| [embedded-hal](https://github.com/rust-embedded/embedded-hal) | Hardware abstraction traits | Portable driver interfaces |
130-
| [embedded-hal-async](https://github.com/rust-embedded/embedded-hal) | Async HAL traits | Async peripheral operations |
131136
| [defmt](https://github.com/knurling-rs/defmt) | Lightweight logging for embedded Rust | Structured firmware logs during development |
132137
| [defmt-rtt](https://github.com/knurling-rs/defmt) | RTT transport for defmt | Real-time debug output |
133138
| [panic-probe](https://github.com/knurling-rs/probe-run/tree/main/panic-probe) | Panic reporting | Panic handling during debugging |
134139
| [heapless](https://github.com/rust-embedded/heapless) | `no_std` data structures | Fixed-capacity buffers/queues for embedded-safe logic |
135-
| [esp-idf-svc](https://github.com/esp-rs/esp-idf-svc) | ESP32 service layer in Rust | Networking/logging and admin-side integration |
136140

137141
## Links
138142

35 KB
Loading
39.7 KB
Loading
26.4 KB
Loading
35.8 KB
Loading
95.1 KB
Loading
53.1 KB
Loading
39.7 KB
Loading
67.5 KB
Loading

0 commit comments

Comments
 (0)