Built to order

Vending Machine with QR Payment and Stock Alerts using ESP32

This project builds a QR-payment vending machine using an ESP32 that sells snacks and drinks, tracks stock with infrared slot sensors, and raises low-stock alerts on a live dashboard. A buyer scans the QR code on the machine, pays through UPI, and the ESP32 drives a servo to dispense the selected item while the dashboard updates the stock count. The 6-slot prototype demonstrates embedded control, sensor-based inventory, Wi-Fi telemetry and cashless payment flow in one working build. Suitable for B.E./B.Tech final-year projects in Electronics, Electrical and IoT & Embedded.

IoT & Embedded HTML · CSS · JavaScript dashboard16x2 LCD displayArduino IDE · Embedded CESP32 · Wi-Fi microcontrollerMG996R servo motorIR slot sensors TCRT5000UPI QR payment flowHybrid
Vending Machine with QR Payment and Stock Alerts using ESP32 — project thumbnail preview
More project photos (2)

The problem

A Vending Machine with QR Payment and Stock Alerts using ESP32 replaces the coin slot of a conventional snack machine with a phone scan, a UPI payment and a live stock dashboard. In college canteens, hostels and small offices, snack counters need a person at the till or a coin-operated machine that jams, needs change and hides what has sold out until a customer complains. This project closes both gaps in one prototype: the buyer scans a QR code printed on the machine, pays the exact price through UPI, and the ESP32 confirms the payment and drives a servo to release the chosen item, while an infrared sensor in every slot watches the stock and the dashboard flags any product that falls below its refill threshold. The result is a compact 6-slot machine that demonstrates embedded control, cashless payment flow, sensor-based inventory and Wi-Fi telemetry in one build a student team can explain end to end.

SYSTEM FLOW

6 components 5 connections

Live flow
Drag to explore
100%
userQR Code

QR sticker on the machine carries the payment identity.

Follow the working sequence

How it works

When a buyer approaches the machine, the 16×2 LCD shows the six products with their prices and the QR code sticker beside the display carries the machine's payment identity. The buyer scans the code with any UPI app, enters the price shown for the chosen slot, and authorises the payment; the ESP32 receives the payment confirmation over Wi-Fi and checks that the selected slot is stocked before it acts. On confirmation, the ESP32 drives the MG996R servo for that slot through a fixed rotation, the pusher releases one item into the collection tray, and the infrared beam across the slot is re-checked to confirm the item actually left. The ESP32 then decrements the stock count, sends the new count to the dashboard, and if the remaining stock has fallen to the refill threshold of 6 units or fewer, the dashboard raises a low-stock alert with the slot number so the operator knows exactly what to refill.

  1. The buyer reads the product list and price on the 16×2 LCD and selects a slot by number.
  2. The buyer scans the machine's QR code with a UPI app and pays the exact price shown for that slot.
  3. The ESP32 receives the payment confirmation over Wi-Fi and verifies the selected slot is stocked via its infrared sensor.
  4. The ESP32 drives the slot's MG996R servo through a fixed rotation, pushing one item into the collection tray.
  5. The infrared beam is re-checked after dispensing to confirm the item left the slot; if the beam is still blocked, the machine reports a jam instead of charging again.
  6. The ESP32 decrements the stock count and sends the updated count to the dashboard over Wi-Fi.
  7. If the remaining stock is at or below the 6-unit threshold, the dashboard raises a low-stock alert naming the slot; the sale is added to the transaction log with time, product and price.

Tech stack:

  • ESP32 · Wi-Fi microcontroller
  • Arduino IDE · Embedded C
  • IR slot sensors · TCRT5000
  • MG996R servo motor
  • 16x2 LCD display
  • HTML · CSS · JavaScript dashboard
  • UPI QR payment flow
  • 12 V power supply · buck converter
Parameter Value
Controller ESP32-WROOM-32 · dual-core 240 MHz (datasheet value)
Product slots 6 slots (design)
Slot sensing IR beam-break per slot · TCRT5000-type sensor
Dispensing MG996R servo · 9.4 kgf·cm stall torque at 4.8 V (datasheet value)
Display 16 × 2 character LCD
Payment QR code + UPI flow · confirmation simulated in the demo (live gateway is an optional extension)
Dashboard update Approximately 2 seconds after a confirmed sale (design target)
Connectivity Wi-Fi 802.11 b/g/n (datasheet value)
Power 12 V · 2 A adapter with 5 V buck converter (design)
Cabinet Approximately 45 × 30 × 25 cm acrylic + aluminium frame (design target)
Demo prices ₹15–₹35 per item (example data)

Project features

The machine's four strongest capabilities are its cashless QR payment flow, its infrared slot sensing, its automatic low-stock alerts and its live sales dashboard. The QR payment flow lets any buyer pay with a UPI app without coins, change or a card reader, and the ESP32 only dispenses after the payment is confirmed, so no item leaves the machine unpaid. Infrared sensors in each of the six slots watch the stock continuously: a stocked item blocks the beam, and when the last item is taken the beam reaches the receiver and the slot is marked empty. The dashboard turns those sensor readings into action by flagging any product at or below the 6-unit refill threshold and by logging every sale with its time, product and price, giving the operator a refill list and a sales record without opening the cabinet.

  • [QR code payment flow] Each product slot carries a price and the machine displays a QR code; the buyer scans it with any UPI app, pays the exact amount, and the ESP32 dispenses only after the payment confirmation arrives over Wi-Fi.
  • [Infrared slot sensing] Every slot has an infrared beam across it. A stocked item blocks the beam; when the last item is taken, the beam reaches the receiver and the ESP32 marks that slot empty on the dashboard.
  • [Low-stock alerts] The dashboard flags any product at or below the 6-unit refill threshold with a visible alert and the slot number, so the operator knows exactly what to refill before the evening rush.
  • [Servo dispensing mechanism] An MG996R servo drives a pusher for the selected slot through a fixed rotation, releasing exactly one item into the collection tray per confirmed payment.
  • [Live sales dashboard] The companion dashboard shows per-product stock, sales today, revenue today and a transaction log with time, product and price for every confirmed sale.
  • [LCD and slot selection] A 16×2 LCD shows the product list with prices and the machine status (READY, PAID, DISPENSING, OUT OF STOCK), so the buyer always knows what the machine is doing.
  • [Refill mode] A refill switch pauses dispensing while the operator restocks; the sensors re-read each slot on resume and the dashboard counts update without a restart.

What is included

  • Working 6-slot vending machine prototype (ESP32, IR sensors, servo dispensing, LCD, QR panel)
  • Complete firmware source code (Arduino IDE, Embedded C)
  • Live stock and sales dashboard demo (single-file HTML/CSS/JS)
  • Circuit diagram, wiring documentation and component list
  • Project report PDF (background, methodology, working, results, limitations)
  • Project abstract PDF
  • PPT presentation for final review
  • Viva Q&A preparation document (ESP32, IR sensing, servo control, QR/UPI flow, Wi-Fi telemetry)

Limitations & prerequisites

  • The demo confirms QR/UPI payment in simulation — a live payment-gateway integration with settlement and refunds is an optional extension, not part of the base build.
  • Dispensing is tuned for light packaged snacks and 200 ml cans; heavy or irregularly shaped items can jam and need a slot redesign.
  • The infrared beam can misread if direct sunlight falls on the sensor or if a transparent wrapper lets the beam through — slots are calibrated in indoor light.
  • Wi-Fi is required for payment confirmation and dashboard updates; without it the machine cannot confirm a payment and will not dispense.
  • The 6-slot cabinet holds approximately 96 items in total (design target), so a busy location needs refilling more than once a day.
  • The prototype is a bench demonstration unit, not a weatherproof or tamper-proof commercial machine, and it has no coin or card fallback.
  • Servo dispensing releases one item per rotation — a failed rotation (jam) is reported, but the machine cannot clear the jam itself.

Frequently Asked Questions

How does the QR payment work?

The machine displays a QR code and the price for each of the 6 slots. The buyer scans the code with any UPI app and pays the exact amount; the ESP32 receives the payment confirmation over Wi-Fi and only then drives the servo to dispense the item. In the demo build the confirmation step is simulated so the full flow can be shown without a live gateway, and a real payment-gateway integration can be added as an optional extension.

How does the machine know a slot is empty?

Each slot has an infrared beam across it, and the sensing rule is simple: a stocked item blocks the beam, while an empty slot lets the beam reach the receiver. The ESP32 reads all 6 beams continuously and marks a slot empty the moment its beam is unbroken. That reading also drives the dashboard count and the low-stock alert, so the operator sees the same stock the machine sees.

Is this project suitable for a final-year project?

Yes — for Electronics, Electrical, IoT & Embedded and Computer Engineering programs. It combines embedded C on the ESP32, sensor interfacing, servo actuation, Wi-Fi telemetry and a payment flow in one demonstrable build, and every subsystem can be shown working live in the viva.

Does it work without internet?

Dispensing needs Wi-Fi, because the ESP32 must receive the payment confirmation and update the dashboard before it releases an item. Without Wi-Fi the machine shows an offline status on the LCD and refuses to dispense, which is deliberate: it prevents an item leaving without a confirmed payment. The LCD and slot sensors still work offline, but no sale completes.

Can more slots or products be added?

Yes, within limits. Each extra slot needs one more IR sensor pair and one more servo channel, and the ESP32 has enough GPIO pins for approximately 10–12 slots in total (design target) before an I/O expander is needed, and each new slot also needs its own pusher and product tray. Prices, product names and the refill threshold are all configurable in the firmware and the dashboard without changing the hardware.

What happens if a payment succeeds but dispensing fails?

The ESP32 re-checks the infrared beam after the servo rotation. If the beam is still blocked, the item did not leave the slot, so the machine shows a jam message on the LCD, logs a failed dispense, and does not count the sale. The operator clears the jam and the buyer is not charged a second time for the same slot.

Components & software requirements
  • ESP32 · Wi-Fi microcontroller
  • Arduino IDE · Embedded C
  • IR slot sensors · TCRT5000
  • MG996R servo motor
  • 16x2 LCD display
  • HTML · CSS · JavaScript dashboard
  • UPI QR payment flow
  • 12 V power supply · buck converter
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download free synopsis (PDF)

Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.

Get a quotation