The Problem with Off-the-Shelf Controllers
+
Most vending machines run on proprietary controllers that are locked down. Want to change the product layout? That's a firmware update. Want to add a new payment method? That's a new board. For a fitness center chain that might want to stock different items at different locations — one location sells pre-workout shakes, another sells yoga mats — this becomes a maintenance nightmare.
Our client wanted a system where the gym manager could log into a web dashboard, drag-and-drop product slots, set dynamic pricing based on time of day, and have the machine update within seconds. No engineer on site. No flashing firmware.
The Hardware Stack
We started with the nRF52840 from Nordic Semiconductor. Why this chip? It gives us Bluetooth 5.2, Thread, and Zigbee support on a single Cortex-M4F core. For a vending machine that might need to talk to gym membership systems, payment terminals, and cloud dashboards, having multiple wireless protocols without extra chips was a big win.
The main board runs Zephyr RTOS. We chose Zephyr over FreeRTOS because of its built-in BLE stack and over-the-air (OTA) update support. The BudKoin platform has to push new product configurations to hundreds of machines — doing that over USB or SD card isn't feasible.
For the cellular backhaul, we added a Quectel BG96 module. This handles the 4G LTE connection for remote monitoring and payment processing. The BLE is for local interactions — the gym member's phone connects directly to the machine to authenticate via the BudKoin app, then the machine talks to the cloud over cellular for the actual transaction.
The Motor Control Problem
Vending machine motors are a pain. Most use 12V DC motors with mechanical switches to detect position. Problem: these switches fail. They wear out, get jammed, or just stop making contact. We've seen machines that think they've dispensed a product when the motor actually stalled.
We designed a custom PCB with DRV8833 motor drivers and Hall effect sensors instead of mechanical switches. The Hall sensors detect the magnet on the motor shaft — no physical contact, no wear. The firmware monitors motor current draw in real time. If the current spikes above a threshold, the motor is stalled. The system retries twice, then marks that slot as “faulted” and sends an alert to the dashboard.
We tested this with over 10,000 cycles per motor. Zero failures on the Hall sensors. The mechanical switches in our test rig started failing around 3,000 cycles.
The Customization Layer
Here's where the “
customizable vending machine ” part comes in. Every BudKoin machine has an EEPROM that stores the product map — which motor corresponds to which slot, what the price is, what image to show on the display. When the gym manager updates the product lineup in the cloud dashboard, the machine pulls down a new product map over MQTT.
The MQTT broker runs on AWS IoT Core. We chose MQTT over HTTP because of the persistent connection — the machine stays connected to the broker 24/7, so updates propagate within seconds. The machine's firmware subscribes to a topic like `budkoin/machine/ABC123/product_map`. When a new message arrives, it writes the new map to EEPROM and reboots the UI.
The UI itself is a 7-inch IPS LCD driven by an ESP32-S3. We kept the ESP32 separate from the main nRF52840 to isolate the display processing. The ESP32 runs Squareline Studio for the UI — it's a drag-and-drop LVGL-based editor that lets us build custom screens without writing C code every time. The gym manager can upload a custom background image, change button colors, and rearrange the product grid. All of that gets stored in a JSON file on the ESP32's flash.
The Payment System
Fitness centers don't want cash. They want members to pay with their membership card or phone. We integrated an NFC reader (PN532) that reads ISO 14443A cards. The machine also supports Apple Pay and Google Pay via the phone's BLE connection.
When a member taps their phone, the BudKoin app generates a one-time token. The machine sends this token to the cloud over the cellular link, the cloud validates it against the member's account, and returns an authorization. The whole transaction takes under two seconds.
For guests, we added a credit card reader (IDTech VP8800) that connects over UART. The machine encrypts the card data and sends it directly to Stripe's API over the cellular connection. We never store card data on the machine.
The 3D Design and Enclosure
The vending machine chassis is a standard 72-inch tall, 39-inch wide cabinet. But the internal layout is modular. We designed a 3D-printed mounting bracket system that lets the gym manager rearrange the motor banks. Each motor bank holds 8 motors and slides into a rail system. The main PCB has four ribbon cable headers for motor banks — plug in up to 32 motors.
The enclosure for the electronics is IP54 rated. We used a combination of laser-cut acrylic for the display bezel and injection-molded ABS for the NFC reader housing. The main board sits in a die-cast aluminum box with thermal pads connecting to the chassis for heat dissipation.
What We Learned
The biggest lesson: separate the UI from the logic. Having the ESP32 handle the display and the nRF52840 handle the control logic meant we could update the UI without touching the motor control code. In production, we've pushed three UI updates over the air without a single machine going offline.
Another lesson: test the motors early. We spent two weeks debugging a motor stall issue that turned out to be a voltage drop in the ribbon cable. The cable had too much resistance for the 2A peak current. We switched to 18AWG wire and the problem disappeared.
Where It's Going
The first BudKoin machines are now in five fitness centers across the US. The gym managers are using the customization features more than we expected — one location changes the product layout every week based on which classes are popular. Another uses dynamic pricing to discount protein bars after 8 PM.
We're working on the next revision. The client wants to add a camera module for inventory tracking — the machine takes a photo of the product row after each dispensation and runs a simple object detection model on the ESP32 to verify the product was actually dispensed. We're looking at the ESP32-S3's built-in vector extension for that.
If you're building a vending machine, or any IoT product that needs to be customizable at the deployment level, the key is separating the hardware from the configuration. Make the firmware generic. Put the customization in the cloud and the EEPROM. Your customers will thank you when they can change the product lineup without calling you at 2 AM.
DigitalMonk specializes in full-stack hardware development — from PCB design and firmware to 3D design and prototype shipping. We've built IoT products for clients in fitness, retail, and industrial automation.We built a
vending machine for fitness centers which is appreciated by users because this vending machine is human friendly. If you have a hardware idea that needs to work, reach out.
Discussie (0 opmerking(en))