Case Study: Raspberry Pi Smart Locker System With Nayax Payment Integration

by Chanchaldada in Circuits > Raspberry Pi

73 Views, 1 Favorites, 0 Comments

Case Study: Raspberry Pi Smart Locker System With Nayax Payment Integration

Screenshot 2026-07-27 151439.png

The Problem: Cash-Only Lockers in a Cashless World

A mid-sized US facility management company came to us with a specific headache. They operated hundreds of rental lockers across gyms, airports, and coworking spaces. Users paid with quarters or tokens. The lockers worked, but the business model was leaking money.

Collections were manual. Coin jams were weekly. And the biggest problem: no remote monitoring. When a locker broke, they didn’t know until a customer complained. They wanted a smart locker system that accepted credit cards, Apple Pay, and tap-to-pay. They also wanted real-time inventory data and the ability to remotely unlock a locker for support.

They needed a hardware partner who could design the electronics, write the firmware, and integrate a payment terminal. That’s where we came in.


Supplies

The Hardware: PCB Design and Power Management

Our team designed a custom carrier board for the CM4. It handles:

- 12V input from the locker’s existing power supply

- 5V and 3.3V regulation for the Pi and sensors

- A MOSFET driver for the solenoid latch

- A reed switch input to detect door open/close

- An I2C interface for an optional temperature/humidity sensor (the client wanted this for gym lockers)

We used KiCad for the schematic and layout. The board is 4-layer, with a dedicated ground plane and isolated power traces to keep the solenoid noise away from the Pi’s USB lines. That mattered because the Nayax terminal shares a USB bus with the Pi.

Why Raspberry Pi? (And Why Not Something Else)

Screenshot 2026-07-27 151439.png

The client’s existing lockers used a simple solenoid latch with a 12V trigger. The control board was a basic microcontroller with no networking. We evaluated a few options:

- ESP32: Cheap, low power, but no native USB host for the payment terminal.

- nRF52: Great for BLE, but we needed Wi-Fi and Ethernet for the payment gateway.

- Raspberry Pi Compute Module 4: Overkill? Maybe. But it gave us USB 2.0, Wi-Fi, Ethernet, and GPIO all on one board. We didn’t need to stack multiple microcontrollers or add a separate USB host chip.

We chose the Raspberry Pi CM4. It runs our custom firmware built on a lightweight Linux image. No desktop environment. Just a headless system that boots in under 8 seconds.


Nayax Payment Integration: the Tricky Part

Screenshot 2026-07-27 151601.png

The client wanted Nayax VPOS Touch terminals. These are EMV-certified, NFC-capable, and support Visa, Mastercard, Amex, and Apple Pay. The terminal communicates over USB, acting as a virtual serial port.

Our firmware handles the Nayax protocol directly. When a user taps their card, the terminal sends a transaction request over USB. Our software parses the message, sends it to Nayax’s cloud gateway via the Pi’s Ethernet, and waits for an approval code. If approved, the Pi energizes the solenoid for 2 seconds to release the latch.

The whole process takes about 1.2 seconds. Faster than the user can pull the door open.

We also added a fallback. If the Pi loses internet, the terminal can store transactions and sync later. The locker defaults to “free” mode during network outages — not ideal for revenue, but better than a broken locker.


Firmware: Zephyr RTOS Vs. Linux

We debated using Zephyr RTOS on a smaller MCU. But the Nayax integration required USB host mode, which Zephyr supports but not as maturely as Linux. We stuck with Linux on the CM4.

Our firmware stack:

- Systemd for service management

- Python 3 for the payment logic and API calls

- C for the GPIO and solenoid control (via libgpiod)

- MQTT for cloud communication

The Pi publishes locker status (door open/closed, transaction history, error codes) to the client’s AWS IoT Core every 30 seconds. They use this data to generate usage reports and predict when a locker needs maintenance.


3D Design and Mechanical Integration

The client’s existing lockers had a metal housing with a cutout for a coin slot. We designed a 3D-printed bezel that replaces the coin slot and holds the Nayax terminal flush against the door.

Our mechanical engineer modeled the bezel in Fusion 360. It includes a mounting flange for the Pi carrier board and a vent slot for the CM4’s heatsink. We printed prototypes in PETG, tested fitment on a real locker, and shipped the final STL files to the client’s injection molding partner.


Prototype to Production: What We Shipped

We delivered 10 fully assembled prototypes:

- Raspberry Pi CM4 with 2GB RAM, 16GB eMMC

- Custom carrier PCB (assembled in India, tested in our Bangalore lab)

- Nayax VPOS Touch terminal with USB cable

- Pre-flashed firmware with MQTT credentials

- 3D-printed bezel

- Wiring harness with JST connectors

The client installed these in three gym locations. After 60 days of testing, they reported zero lockouts, a 40% increase in revenue (cash users switched to card), and a 70% reduction in support tickets.


Lessons Learned

USB power sequencing matters. The Nayax terminal draws 500mA during boot. If the Pi and terminal power on simultaneously, the voltage regulator can brown out. We added a power-good signal from the terminal’s enable pin to delay the Pi’s boot by 500ms.

- Solenoid kickback is real. Without a flyback diode, the MOSFET driver would latch open. We added a Schottky diode across the solenoid coil. Problem solved.

- Test the network early. The client’s gym had weak Wi-Fi in the locker area. We switched to Ethernet for the production units. The Pi’s built-in Ethernet port saved us from adding a USB-to-Ethernet dongle.


Why Hire Raspberry Pi Developers for Smart Vending Machine Software?

Screenshot 2026-07-27 151512.png

This project is a good example of why you don’t want to roll your own hardware if you’re not an embedded systems shop. The Raspberry Pi is accessible, but integrating a payment terminal, designing a carrier board, and writing reliable firmware that runs 24/7 takes experience.

Our team has done this before — for vending machines, EV chargers, and industrial kiosks. If you’re building smart vending machine software or a connected locker system, we can take you from concept to production. We handle the PCB layout, firmware, cloud integration, and even the 3D design for enclosures.

That is why we choose raspberry pi developers for smart vending machine software. We shipped these prototypes within 10 weeks of the first kickoff call. The client is now piloting in 20 more locations. If your project needs that kind of speed, reach out.


DigitalMonk builds embedded systems for companies that need custom hardware, firmware, and cloud connectivity. We’re based in India with offices in the US and UK. We ship prototypes, not promises.