Smart locker cabinet: 100 compartments, unlocked from a phone
Each compartment belongs to one customer, who opens it from the mobile app. This document covers the cabinet's mechanics, electronics, wiring, software and security, with a 3D model and STEP file for the manufacturer.
100compartments, 10 × 10 grid
100 × 120 × 100 mmusable compartment W × D × H
overall width × depth × height
12 V · RS485locks and control bus
≈ 15 hbattery backup (estimate)
Prototype animation, rendered from the 3D model at scale. Not footage of a built unit.
System architecture
Plate 1
The app never talks to the locks directly. Every request goes through the backend, which checks that the customer owns the compartment before it sends a signed command to the cabinet. The cabinet keeps one outbound connection to the MQTT broker, so no port is opened on the site network.
Interactive 3D model
Plate 2
At scale, in millimetres. It opens on the technical plinth with the doors and service hatch hidden. Click any part for its name, size and position.
Click a partIts name, dimensions and position appear here.
Drag to orbit · scroll or pinch to zoom · right-drag or Shift-drag to pan. On a touch screen, swipe sideways to rotate, pinch to zoom, and swipe up or down to scroll the page.
General arrangement drawings
Plate 3
Main dimensions in mm. Steel sheet is 1.5 mm. Each column is 128 mm wide: a 100 mm compartment, a 1.5 mm divider, a 25 mm lock strip and another 1.5 mm divider.
Front elevation
Side section
Door 1.5 mm, left hinge with ejection spring
Compartment depth 120 mm
Rear cavity 40 mm for cable ducts, closed by a removable screwed panel
Technical plinth 100 mm high, front service hatch with key lock
Wiring and signal path
Plate 4
Pick a compartment and run an unlock to follow the command from the app to the lock. You can also simulate a mains or internet outage.
Data Power 12 V / 5 V Active path Bus termination
Choose a compartment, then run the unlock.
Connection list
From
To
Cable
Mains 230 V
IEC inlet (switch + fuse) → PSU 12 V 5 A
3-core mains cable
PSU 12 V output
DC UPS module → battery and load output
1 mm², red/black
UPS load output
5 A fuse → board 1 power input
1 mm², red/black
Board 1 → 2 → 3
Cascade ports P1 / P2
Supplied 4-wire cable
Raspberry Pi USB
USB-RS485 converter
Direct plug
Converter A, B, GND
Board 1 A, B, GND
Twisted pair (e.g. Cat5e pair)
UPS load output
Buck 12→5 V → Raspberry Pi USB-C
5 V 3 A
Each board channel
Its lock (coil + door sensor)
Supplied harness, via ducts
Five rules for a first-time-right install
Give each board a unique address (01, 02, 03) with its DIP switches or buttons.
Don't swap A and B. If nothing answers, check this first.
Tie every ground (GND) together: PSU, boards and converter.
Fit a 120 Ω termination on the last board of the chain. It's often on-board, enabled by a jumper.
Fuse the 12 V output at 5 A.
Only one lock fires at a time. A pulse draws about 1 A for 0.5 s, so a 5 A supply leaves good margin. Never trigger several locks at once from the software.
Bill of materials
Plate 5
Prices are indicative ranges in euros, excluding labour and VAT. They vary a lot by supplier and quantity, so get quotes before ordering.
Item
Reference / spec
Qty
Unit (€)
Total (€)
Technical component placement
Plate 6
Centre position of each part, in mm. The origin is the front-bottom-left corner. X runs to the right, Y to the rear and Z upwards: the same frame as the STEP file.
Part
Qty
W × D × H
X
Y
Z
Software
Plate 7
Unlock sequence
The customer taps “Open compartment 57”. The app sends the request with its session token over HTTPS.
The backend checks the token and that compartment 57 is assigned to this customer. It then signs a short-lived command.
The backend publishes it to cabinet/cab-001/cmd/open.
The Pi verifies the signature and expiry, then maps 57 to board 2, channel 9.
The Pi writes the RS485 frame. The board pulses 12 V on channel 9 and the door springs open.
The Pi reads the door sensor and publishes the event. The app shows “Compartment 57 open” and the backend logs it.
This is the format commonly used by these lock control boards: 9600 baud, 8N1. The checksum (BCC) is the XOR of all the preceding bytes.
Command
Frame
Example
Unlock one lock
8A addr ch 11 BCC
8A 02 09 11 90 = compartment 57
Read status
80 addr 00 33 BCC
80 02 00 33 B1
Check the exact frame format, channel numbering and reply layout against the protocol sheet of the boards you buy. They vary between models.
Cabinet controller service (Python sketch)
# locker_service.py - Raspberry Pi cabinet controller (sketch)
import hashlib, hmac, json, time
import serial # pip install pyserial
import paho.mqtt.client as mqtt # pip install paho-mqtt (v2)
CABINET_ID = "cab-001"
BROKER = "mqtt.example.com"
PORT = "/dev/ttyUSB0" # USB-RS485 converter
LOCKS_PER_BOARD = 48
LOCKER_COUNT = 100
SECRET = open("/etc/locker/secret", "rb").read().strip()
bus = serial.Serial(PORT, 9600, timeout=0.3)
seen = set() # used requestIds (replay protection)
def bcc(data):
x = 0
for b in data:
x ^= b
return x
def locate(locker):
board = (locker - 1) // LOCKS_PER_BOARD + 1
channel = (locker - 1) % LOCKS_PER_BOARD + 1
return board, channel
def send(frame, reply_len):
bus.reset_input_buffer()
bus.write(frame + bytes([bcc(frame)]))
return bus.read(reply_len)
def unlock(locker):
board, ch = locate(locker)
return send(bytes([0x8A, board, ch, 0x11]), 5)
def verify(cmd):
body = f'{cmd["locker"]}|{cmd["requestId"]}|{cmd["exp"]}'.encode()
sig = hmac.new(SECRET, body, hashlib.sha256).hexdigest()
return (hmac.compare_digest(sig, cmd.get("sig", ""))
and cmd["exp"] > time.time()
and cmd["requestId"] not in seen
and 1 <= int(cmd["locker"]) <= LOCKER_COUNT)
def on_connect(client, userdata, flags, reason_code, properties):
client.publish(f"cabinet/{CABINET_ID}/status", "online", qos=1, retain=True)
client.subscribe(f"cabinet/{CABINET_ID}/cmd/open", qos=1)
def on_message(client, userdata, msg):
try:
cmd = json.loads(msg.payload)
if not verify(cmd):
return
seen.add(cmd["requestId"])
reply = unlock(int(cmd["locker"]))
client.publish(f"cabinet/{CABINET_ID}/event/unlock", json.dumps({
"locker": cmd["locker"], "requestId": cmd["requestId"],
"ok": len(reply) > 0, "ts": int(time.time())}), qos=1)
except (ValueError, KeyError):
pass # malformed command: ignore and log
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id=CABINET_ID)
client.tls_set(ca_certs="/etc/locker/ca.pem",
certfile=f"/etc/locker/{CABINET_ID}.crt",
keyfile=f"/etc/locker/{CABINET_ID}.key")
client.will_set(f"cabinet/{CABINET_ID}/status", "offline", qos=1, retain=True)
client.on_connect = on_connect
client.on_message = on_message
client.connect(BROKER, 8883)
client.loop_forever()
Dependencies: pip install paho-mqtt pyserial. Run it as a systemd service with automatic restart. This is a starting point, not production code: add a reply parser, retries, a door-state poller and local logging.
Security and resilience
Plate 8
Access control
The app never addresses a lock directly. The backend checks ownership on every request.
Commands are signed (HMAC or Ed25519), single-use and expire within 30 s.
Optional presence check: the customer scans a QR code on the cabinet or is within BLE range.
Transport
TLS everywhere: HTTPS for the app, MQTT on port 8883 for the cabinet.
One client certificate per cabinet, revocable from the backend.
The broker's ACLs restrict each cabinet to its own topics.
Power and network outages
The DC UPS and battery keep the cabinet running for about 15 h (7 Ah at about 4 W idle).
Offline mode: BLE with a pre-issued, signed and time-limited token stored in the app. Events sync when the cabinet reconnects.
Fail-secure locks stay locked without power.
Physical
1.5 mm steel, with the hatch and rear panel under key or tamper-proof screws.
Mechanical override for the service team, logged on use.
Anchor the cabinet to the wall and floor.
Audit
Every request, unlock and door event is logged with the user, time and result.
Alert when a door is left open too long, or opens without a command.
Device hardening
Read-only root filesystem or overlay. SSH by key only, or disabled.
Automatic security updates and a hardware watchdog.
Secrets stored outside the code with restricted file permissions.
Build roadmap
Plate 9
Use cases
Plate 10
Real places where the cabinet replaces a slow, manual hand-over.
Use case 1
Cannabis social clubs and coffee shops
Today: the club keeps each member's portion in a shared drawer, with the member number written on the pouch. As pouches pile up, staff have to dig through the drawer to find the right one. Hand-overs get slow at busy times and mistakes happen.
With the cabinet: each member gets a personal locker.
The member opens their locker from the club app, only while on site (QR code or Bluetooth check).
They put their pouch in or take it out themselves. Staff no longer handle numbered bags.
The door locks itself when closed, and every opening is logged with the member and the time.
It keeps working during a power or internet cut: the battery takes over and members open their locker over Bluetooth.
The counter stays free for the work that needs a person.