**The Core: Control and Connectivity**
Every smart vending machine needs a brain. In our projects, we typically choose the nRF52840 for its BLE and Thread support, or the ESP32-S3 when Wi-Fi and Bluetooth are both required. The ESP32 handles the heavy lifting for cloud connectivity — sending telemetry data like temperature, inventory levels, and transaction logs to a backend server via MQTT. The nRF52 runs the low-level control loops: motor drivers for the coils, temperature sensors for the cooling unit, and the user interface.
We’ve seen designs that try to run everything on a single Raspberry Pi. That works for a prototype, but in production, it’s a reliability nightmare. A Pi has no real-time guarantees. If the OS hangs during a transaction, you lose a sale. That’s why we separate real-time control (on a microcontroller) from high-level logic (on a Linux board or cloud server). The MCU handles the moment-to-moment operations; the application processor handles the business logic.
**Firmware: Predictable and Safe**
Firmware for a vending machine isn’t just about making things spin. It’s about safety. If a motor jams, the firmware must detect the stall current and stop before the motor burns out. If the temperature in a refrigerated unit rises above a threshold, the firmware should trigger an alert and, if necessary, shut down the cooling compressor to prevent damage.
We build our firmware on Zephyr RTOS. It gives us deterministic scheduling, which is critical when you have multiple tasks running — reading a barcode scanner, polling a temperature sensor, and updating an LED display — all at the same time. Zephyr’s power management also lets us put the MCU into deep sleep between transactions, which matters when the machine is battery-powered or solar-powered for outdoor installations.
Himanshu Dada