Vault room: build and bench guide
STM32 course project. Black Pill (STM32F401CCU6). Last update 2026-12-02. Source: robotics-vault/lead, branch vault/integration.
Where we are
| Part | State |
|---|---|
| Wood: floor base | assembled |
| Wood: walls, vaults, doors | not started |
| Black Pill + flashing over USB | works |
| Buzzer, keypad (16/16 keys), door switch, USB log | tested |
| Fire alarm + sensor-fault detection | tested, pass |
| Tamper alarm | logged, sound check pending |
Room program (vault, 16 features) | written and built, not yet run on the board |
| 12 V lock | blocked: needs the DC jack |
| Servo, LCD, NFC, vibration | blocked: parts or soldering |
Paused until the shop visit. The pins of the Black Pill are not soldered, so wedged jumpers keep falling out.
Next session
At the shop
- Solder the Black Pill's two pin strips and the LCD's small I2C board.
- Buy: DC female jack to 2-pin screw terminal (the 12 V adapter's round plug goes into it; about 10 EGP at RAM).
- Buy: PN532 NFC module (was out of stock at RAM on 2026-11-26: ask, or another shop).
- Buy: SW-18020P vibration switch.
- Buy: MG996R servo, if you don't have it.
Back home, in this order
- Plug the Black Pill into the breadboard. Wire keypad, buzzer, door switch, tamper switch and NTC (see Wiring).
- Flash the room program:
make -C firmware/log T=vault flash, then test the 10 features that need no new parts. - Lock through the TIP120 (needs the DC jack).
- Servo, LCD, then NFC with the phone.
Flashing the Black Pill
The board keeps WeAct's loader in its first 16 KB, so programs start at 0x08004000.
- Hold KEY, tap NRST, keep holding until the blue LED blinks, release.
- Hold KEY again about 3 s until the LED flashes, release. The board is now in DFU (
0483:df11). - On the laptop:
make -C firmware/log T=vault flash(orT=t8_fire_tamper,t5_keylog, …). - Read what the board says:
make -C firmware/log monitor(it appears as/dev/ttyACM0).
Flashing needs the board on a USB port of the machine running the command: the laptop, not the server.
Wiring
Pin map source: wiring/pinmap.csv. Switch modules read LOW when the lever is pressed.
| Part | Connect | Board pin | Notes |
|---|---|---|---|
| Keypad 4x4 (8 holes, left to right) | 1 2 3 4 / 5 6 7 8 | B12 B13 B14 B15 / B5 B8 B9 B10 | rows then columns |
| Buzzer SFM-27-11 (3-24 V) | red = +, black = − | red → A8, black → G | intermittent type: it chops its own tone |
| Room door switch | VCC, GND, S | 3V3, G, A15 | |
| Vault A / vault B door switches | VCC, GND, S | 3V3, G, B3 / B4 | |
| Tamper switch (electronics box lid) | VCC, GND, S | 3V3, G, A0 | lid closed holds the lever pressed |
| Fire: NTC 10k (all black, no stripes) | resistor 10-12 kΩ 3V3 → middle; NTC middle → G | middle → A1 | reading drops when hot; 0 = 3V3 side loose, ~4095 = G side loose |
| Vibration switch | 2 legs | A7 and G | not bought yet |
| Room lock / vault A lock | see the lock circuit below | B0 / B1 | needs the DC jack |
| Servo (vault B) | signal via 1 kΩ | A6 | power from the 5 V step-down, never from the board |
| LCD 1602 + I2C board | SCL, SDA | B6, B7 | needs soldering |
| PN532 NFC | TX, RX (serial) | A10, A9 | not bought yet |
Lock circuit (per lock)
TIP120 with its printed face toward you, legs down: legs 1 2 3 from left to right.
| From | To |
|---|---|
| Board B0 | 1 kΩ resistor (brown-black-red) → TIP120 leg 1 |
| TIP120 leg 2 | lock wire 1, and the diode's plain end |
| 12 V + (DC jack) | lock wire 2, and the diode's stripe end |
| TIP120 leg 3 | board G and the 12 V − (one shared ground) |
The 12 V never touches a board pin. Plug the adapter into the wall last. Never run the lock without the diode (1N4007, black, one silver stripe, "MIC …4007").
Features (phase 1)
Full list with keypad keys: firmware/FEATURES.md. The decision logic is in assembly (vault.s, features.s).
| # | Feature | Scenario | State |
|---|---|---|---|
| 1 | Phone authentication with cryptography (challenge + ECDSA P-256) | 1 Room entry | needs PN532 |
| 2 | PIN unlock | 1 | coded |
| 3 | Mechanical auto-relock | 1, 3 | with the doors |
| 4 | Vault B servo latch | 2 | needs servo |
| 5 | Two-person rule (vault A) | 3 | coded |
| 6 | Time delay before vault A opens | 3 | coded |
| 7 | Duress PIN (opens normally, long vault delay) | 4 | coded |
| 8 | Vibration / drill alarm + lockout | 5 | coded, switch not bought |
| 9 | Fire alarm | 6 | pass |
| 10 | Escape without power (LIFT TO EXIT) | 6 | with the door |
| 11 | Electronics-box tamper alarm | 7 | sound check pending |
| 12 | Sensor-fault detection | 6 | pass |
| 13 | Forced-door alarm | new | coded |
| 14 | Door-left-open reminder | new | coded |
| 15 | Wrong-PIN lockout | new | coded |
| 16 | Change PIN, kept with power off | new | coded |
Phase 2 (later): Wi-Fi silent alert + heartbeat, vault weight sensor, NFC item tags, ST-LINK.
Buzzer sounds
| Sound | Means |
|---|---|
| continuous | fire |
| 1 s on, 1 s off | tamper, forced door or drill |
| short blip every 2 s | keypad locked out |
| 400 ms every 2 s | door left open |
| short blip every 3 s | temperature sensor wire loose |
Bench results
| Test | Result |
|---|---|
| t1 blink (assembly) | pass |
| t2 buzzer (assembly) | pass (loose contact) |
| t4/t5 keypad + USB log | pass, all 16 keys, all 8 wires |
| t6 door switch | pass (pressed = LOW) |
| t8 fire | pass: room 1668 → heated 1447 = alarm → cooled 1669 = cleared |
| t8 tamper | edges logged, sound check pending |
| t7 lock | not run: DC jack |
Full log: firmware/tests/BENCH-LOG.md.
Gotchas we hit
- Buzzer polarity: red = +, black = −.
- Short beeps get swallowed: the SFM-27-11 is intermittent; alarms use slow rhythms.
- Loose wedged jumpers can touch a neighbour and drop the board off USB. Fix: soldering.
- USB "error -110" after flashing: the WeAct loader leaves interrupts on; every program clears them at start (already in the code).
- The adapter's round plug needs the DC jack; plain jumpers don't reach its contacts.
- Resistors: brown-black-red = 1 kΩ (lock), brown-black-orange = 10 kΩ, the NTC is all black.
- BC547 (half-round, 3 legs) is the buzzer transistor, not a diode.
- Phases come from the
tiercolumn ofwiring/bom.csv.