Close
0%
0%

Raspberry Pi Smart Locker System with Nayax

A smart locker system running on a Raspberry Pi 4, paired with a Nayax VPOS payment terminal.

Public Chat
Similar projects worth following
We've all been there. You need to pick up a package from a locker, but the interface is clunky, the screen is unresponsive, and you're left jabbing at a resistive touch panel from 2008. Or worse — you run a small business selling specialty goods, and you're stuck with off-the-shelf vending machines that don't fit your product dimensions.

So we built our own. A smart locker system running on a Raspberry Pi 4, paired with a Nayax VPOS payment terminal. It's a customizable vending machine that handles cashless payments, remote inventory tracking, and live door status monitoring. And it ships as a complete prototype — PCB, firmware, 3D-printed enclosure, the works.

Why We Built This

A client came to us — an **IoT product development company** — needing a vending solution for high-value, oddly-shaped items. Think electronics components, artisanal tools, or curated subscription boxes. Standard vending machines couldn't handle mixed product sizes. And the payment integration? A nightmare of proprietary protocols and locked-down firmware.

We wanted something that:

- Works with modern payment systems (NFC, credit cards, mobile wallets)

- Lets you reconfigure locker sizes without rewiring

- Reports inventory and door status in real time

- Doesn't require a PhD in embedded systems to maintain

So we spec'd out a system around a Raspberry Pi 4 (4GB), a Nayax VPOS Touch, and a bank of solenoid-driven locker doors. Total BOM cost? Around $180 per 12-locker unit, not including the terminal.

Features

Payment agnostic. The Nayax VPOS handles Visa, Mastercard, Amex, Apple Pay, Google Pay, and even WeChat Pay. We talk to it over a simple serial UART connection — no proprietary SDK lock-in.

Modular locker architecture. Each locker door has a magnetic reed switch for status sensing and a 12V solenoid for release. We used a MCP23017 I/O expander over I2C to control 16 solenoids from a single Pi. Need more lockers? Add another expander.

Real-time dashboard. The Pi runs a Node-RED instance that publishes door status, transaction logs, and inventory levels over MQTT. We feed this into a Grafana dashboard hosted on a $5/month VPS. You can see exactly which locker is empty, which one just dispensed, and how much revenue came in today.

Fail-safe operation. If the Pi crashes mid-transaction, the Nayax terminal still records the payment. We log all events to a local SQLite database and sync to the cloud when the connection returns. No lost revenue.

rpi-smart-locker-architecture.webp

WebP Image - 40.10 kB - 07/23/2026 at 12:33

Download

  • 1 × Raspberry Pi 4
  • 1 × Nayax VPOS Touch
  • 1 × 12V Solenoid
  • 12 × I/O Expander
  • 2 × 12V 5A PSU

View all 8 components

  • About Project

    Himanshu Dadaan hour ago 0 comments

    We didn't just throw parts on a breadboard. The PCB is a custom 2-layer board designed in KiCad 7.0. It routes the I2C bus, power distribution for solenoids, and screw terminals for each reed switch. The enclosure is a stack of 3D-printed PLA trays — each tray holds four lockers. We used Fusion 360 for the mechanical design and printed on a Bambu Lab X1 Carbon. Took about 14 hours total print time.

    The firmware is written in C using the WiringPi library on Raspberry Pi OS Lite (64-bit). The Nayax integration uses a custom serial protocol — we send a simple ASCII command like `PAY 1.50` and get back `APPROVED` or `DECLINED`. No JSON, no REST, just clean serial.

    Applications

    This isn't a one-trick pony. We've deployed variants for:

    - Workshop tool checkouts — mechanics grab a socket set, scan their badge, door pops open

    - Pharmacy lockers — prescription pickup with insurance card reader (Nayax handles the PCI compliance)

    - Electronics component vending — resistors, caps, dev boards in individual cubbies

    - Food truck pickups — pre-ordered meals stored in temperature-controlled lockers

    The key is the customizable vending machine architecture. You can swap the Nayax for a different terminal, change locker sizes by editing the 3D model, or add sensors (we're testing a load cell for weight-based inventory detection).

    Future Improvements

    We're working on three upgrades:

    Battery backup. A 12V 7Ah SLA battery keeps the system running for 4 hours during power outages. The Pi will gracefully shut down if the battery drops below 11V.

    Matter protocol support. We're porting the MQTT layer to Matter over Thread using an nRF52840 as a coprocessor. This lets the lockers integrate with smart home systems — imagine your Google Home telling you "Package delivered to Locker 3."

    AI-assisted restocking. We're training a YOLOv8 model on images from a USB camera to detect empty lockers. Initial tests show 94% accuracy on a dataset of 200 images. Overkill? Maybe. Fun? Absolutely.

    Conclusions

    This project proves you don't need a million-dollar contract with a vending machine OEM to build a smart retail system. With a Raspberry Pi, a Nayax terminal, and some off-the-shelf hardware, you can create a personalized vending machine  that handles real payments, reports live data, and fits your exact product dimensions.

    We're an IoT product development company that ships working prototypes — not PowerPoint slides. If you need a similar system for your business, we can take this reference design and adapt it to your use case. Same architecture, different form factor. That's the point.

    The files are on GitHub (KiCad schematics, Fusion 360 models, and the full firmware). Go build one. Then tell us what you broke — we'll help you fix it.

View project log

  • 1
    Assemble the PCB

    Solder the MCP23017, terminal blocks, and header pins. We used a hot air station at 300°C for the SOIC package — took about 20 minutes.

  • 2
    Wire the solenoids

    Each solenoid gets +12V from the PSU and ground through a MOSFET (IRLZ44N) controlled by the MCP23017. Add a flyback diode (1N4007) across each coil.

  • 3
    Mount the reed switches

    Hot glue them to the locker door frame. The magnet goes on the door itself. Wire the switch to the screw terminal — one side to 3.3V, the other to the expander input.

View all 7 instructions

Enjoy this project?

Share

Discussions

Does this project spark your interest?

Become a member to follow this project and never miss any updates