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

PartState
Wood: floor baseassembled
Wood: walls, vaults, doorsnot started
Black Pill + flashing over USBworks
Buzzer, keypad (16/16 keys), door switch, USB logtested
Fire alarm + sensor-fault detectiontested, pass
Tamper alarmlogged, sound check pending
Room program (vault, 16 features)written and built, not yet run on the board
12 V lockblocked: needs the DC jack
Servo, LCD, NFC, vibrationblocked: 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

  1. Solder the Black Pill's two pin strips and the LCD's small I2C board.
  2. Buy: DC female jack to 2-pin screw terminal (the 12 V adapter's round plug goes into it; about 10 EGP at RAM).
  3. Buy: PN532 NFC module (was out of stock at RAM on 2026-11-26: ask, or another shop).
  4. Buy: SW-18020P vibration switch.
  5. Buy: MG996R servo, if you don't have it.

Back home, in this order

  1. Plug the Black Pill into the breadboard. Wire keypad, buzzer, door switch, tamper switch and NTC (see Wiring).
  2. Flash the room program: make -C firmware/log T=vault flash, then test the 10 features that need no new parts.
  3. Lock through the TIP120 (needs the DC jack).
  4. 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.

  1. Hold KEY, tap NRST, keep holding until the blue LED blinks, release.
  2. Hold KEY again about 3 s until the LED flashes, release. The board is now in DFU (0483:df11).
  3. On the laptop: make -C firmware/log T=vault flash (or T=t8_fire_tamper, t5_keylog, …).
  4. 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.

PartConnectBoard pinNotes
Keypad 4x4 (8 holes, left to right)1 2 3 4 / 5 6 7 8B12 B13 B14 B15 / B5 B8 B9 B10rows then columns
Buzzer SFM-27-11 (3-24 V)red = +, black = −red → A8, black → Gintermittent type: it chops its own tone
Room door switchVCC, GND, S3V3, G, A15
Vault A / vault B door switchesVCC, GND, S3V3, G, B3 / B4
Tamper switch (electronics box lid)VCC, GND, S3V3, G, A0lid closed holds the lever pressed
Fire: NTC 10k (all black, no stripes)resistor 10-12 kΩ 3V3 → middle; NTC middle → Gmiddle → A1reading drops when hot; 0 = 3V3 side loose, ~4095 = G side loose
Vibration switch2 legsA7 and Gnot bought yet
Room lock / vault A locksee the lock circuit belowB0 / B1needs the DC jack
Servo (vault B)signal via 1 kΩA6power from the 5 V step-down, never from the board
LCD 1602 + I2C boardSCL, SDAB6, B7needs soldering
PN532 NFCTX, RX (serial)A10, A9not bought yet

Lock circuit (per lock)

TIP120 with its printed face toward you, legs down: legs 1 2 3 from left to right.

FromTo
Board B01 kΩ resistor (brown-black-red) → TIP120 leg 1
TIP120 leg 2lock wire 1, and the diode's plain end
12 V + (DC jack)lock wire 2, and the diode's stripe end
TIP120 leg 3board 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).

#FeatureScenarioState
1Phone authentication with cryptography (challenge + ECDSA P-256)1 Room entryneeds PN532
2PIN unlock1coded
3Mechanical auto-relock1, 3with the doors
4Vault B servo latch2needs servo
5Two-person rule (vault A)3coded
6Time delay before vault A opens3coded
7Duress PIN (opens normally, long vault delay)4coded
8Vibration / drill alarm + lockout5coded, switch not bought
9Fire alarm6pass
10Escape without power (LIFT TO EXIT)6with the door
11Electronics-box tamper alarm7sound check pending
12Sensor-fault detection6pass
13Forced-door alarmnewcoded
14Door-left-open remindernewcoded
15Wrong-PIN lockoutnewcoded
16Change PIN, kept with power offnewcoded

Phase 2 (later): Wi-Fi silent alert + heartbeat, vault weight sensor, NFC item tags, ST-LINK.

Buzzer sounds

SoundMeans
continuousfire
1 s on, 1 s offtamper, forced door or drill
short blip every 2 skeypad locked out
400 ms every 2 sdoor left open
short blip every 3 stemperature sensor wire loose

Bench results

TestResult
t1 blink (assembly)pass
t2 buzzer (assembly)pass (loose contact)
t4/t5 keypad + USB logpass, all 16 keys, all 8 wires
t6 door switchpass (pressed = LOW)
t8 firepass: room 1668 → heated 1447 = alarm → cooled 1669 = cleared
t8 tamperedges logged, sound check pending
t7 locknot run: DC jack

Full log: firmware/tests/BENCH-LOG.md.

Gotchas we hit