How It Works

A complete breakdown of the machine's hardware, software, and process flow — from bottle insertion to points credited to your account.

Complete Process Flow

Step 1

Resident Checks In on the Website

Before depositing, the resident logs into the site and starts a Deposit Session for the machine they're standing at. This tells the system who to credit — the machine itself has no way to identify a person, so the website is how it knows.

pages/deposit.php — live session, ±10 min window
Step 2

Resident Inserts Plastic Bottle

The resident places a used PET plastic bottle into the front input slot of the machine. The slot is sized to accept standard plastic bottles commonly found in Barangay Muzon.

Physical enclosure with designed input slot
Step 3

Inductive Sensor Screens for Metal

This runs continuously and takes priority over everything else: an inductive sensor checks for metal the instant something enters the slot. If metal is confirmed (3 consecutive readings, to avoid false triggers), the item is rejected immediately — no further checks needed.

Inductive sensor (via PC817 opto-isolator) — Priority 1 trigger
Step 4

Ultrasonic Sensor Detects the Bottle

If no metal was detected, an HC-SR04 ultrasonic sensor watches the slot for an object within range. Once something is detected consistently, the system pauses briefly to let the item settle before validating it.

HC-SR04 ultrasonic sensor — Priority 2 trigger
Step 5

Capacitive Sensor Confirms Plastic

A capacitive sensor checks whether the object is plastic, while the inductive sensor does one final metal re-check at the same time. Only an item that reads "plastic" and "not metal" is accepted.

Capacitive sensor (via PC817 opto-isolator)
Step 6

Microcontroller Processes & Decides

Based on the sensor readings, the ESP32 makes the final call: Accept or Reject. If valid, the servo motor opens the gate. If invalid, the LCD shows the reason and the item stays out of the bin.

ESP32 microcontroller (C++ logic)
Step 7

Servo Motor Opens Gate

A servo motor rotates to open the acceptance gate, allowing the bottle to fall into the collection bin. It then closes automatically to await the next item.

SG90 / MG996R Servo Motor
Step 8

LCD Shows Feedback

The 16×2 LCD display shows the result — "Accepted!", "Rejected — Metal Detected", or "Rejected — Not Plastic" — giving the resident clear, immediate visual feedback on the transaction.

16×2 I2C LCD Display Module
Step 9

Points Credited Automatically

If a deposit session is active for that machine, the accepted bottle credits points straight to the resident's account in real time — no physical reward is dispensed by the machine itself. Forgot to check in? A manual claim can still be reported and cross-checked by an admin afterward.

includes/session.php — instant crediting via active session
Step 10

Points Redeemed for Rewards

Once points build up, the resident redeems them from the Rewards page for items like water, biscuits, or an eco bag. An admin reviews and hands over the item — points are only spent once approved.

pages/rewards.php · admin/redemptions.php
Step 11

Data Sent to Web Dashboard

The ESP32 sends transaction and bin-level data over WiFi to the PC running XAMPP. A second ultrasonic sensor mounted above the bin also reports fill level every few seconds. PHP receives the data and stores it in MySQL for real-time monitoring on the public dashboard and admin panel.

ESP32 (WiFi/HTTP) → PHP → MySQL (XAMPP)

Hardware Components

ComponentModel / SpecificationQtyPurpose
ESP32 MicrocontrollerESP32 Dev Module (WiFi + Bluetooth)1Main controller — reads all sensors, drives outputs, and talks to the PHP backend over WiFi
Inductive SensorLJ12A3-4-Z/BX (via PC817 opto-isolator)1Primary trigger — detects metal and rejects it immediately, before any other check
Ultrasonic Sensor — BottleHC-SR041Detects a bottle entering the slot and measures it to confirm a valid size
Capacitive SensorLJC18A3-B-Z/BX (via PC817 opto-isolator)1Confirms the detected object is plastic before the gate opens
Ultrasonic Sensor — Bin LevelHC-SR041Second unit, mounted above the collection bin — measures fill level continuously
Servo MotorSG90 or MG996R1Controls the acceptance gate — opens on a valid bottle, closes after
LCD Display16×2 with I2C adapter (PCF8574, addr 0x27)1Shows feedback to the resident — "Accepted", "Rejected", or "Bin Full"
Buzzer5V Active Buzzer1Audio feedback for accepted / rejected bottle events
LED IndicatorsGreen / Red 5mm LEDs2Visual accept/reject signal for the user
Power Supply5V 2A DC Adapter1Powers the ESP32 and all connected peripherals
Jumper WiresMale-to-male / Male-to-female30+Circuit connections between components
Breadboard / PCBFull-size breadboard1Prototyping and circuit assembly
Machine EnclosureWood / PVC / Acrylic box1Physical housing for the entire system

The Software Stack

Layer 1 — ESP32 Firmware (C++)
Inductive sensor check (metal — Priority 1) Ultrasonic distance measurement (bottle size + bin level) Capacitive validation (plastic confirmation) Servo motor control (open / close gate) LCD display output ("Accepted" / "Invalid") Buzzer & LED feedback WiFi HTTP POST to PHP backend
↓   WiFi — HTTP POST (form data)   ↓
Layer 2 — PHP Web Application (XAMPP / Apache)
api/receive_data.php — logs each transaction, credits an active session api/machine_ping.php — bin-level heartbeat every ~5s pages/deposit.php — resident check-in / live deposit session pages/rewards.php — points balance & reward redemption pages/data.php — public live dashboard admin/credit_requests.php, redemptions.php — admin review queues includes/session.php, rewards.php — points & session logic
↓   MySQLi Queries   ↓
Layer 3 — MySQL Database (bottleback)
transactions — one row per bottle event (accepted / rejected) machine_status — live bin level & online status users — resident accounts & points_balance deposit_sessions — active check-ins, tie a transaction to a resident credit_requests — fallback manual claims, admin cross-checked redemptions — points spent on rewards, admin approved app_settings, reward_catalog — admin-editable points config notifications — bin-level alerts for admins

Studies that support this project

Design of a Plastic Bottle Recycling Machine

Arslan & Tahan (2021)

Shows how reverse vending machines make recycling easier and more accessible by offering rewards, supporting this project's core approach.

Arduino-Based Waste ATM for Recycling Awareness

Jamas, Irwanto & Permata (2024)

Demonstrates automated plastic bottle collection using Arduino and capacitive/ultrasonic sensors — directly paralleling this project's hardware design.

Smart Reverse Vending Machine for Plastic Bottles

Rao et al. (2023)

Uses Arduino Uno, IR sensors, and load cell to detect and validate bottles. Users receive instant coin rewards — similar reward-based model.

VENDOBIN — IoT-Based Plastic Bottle Disposal Machine

Dacay et al., USTP (2023)

Local Philippine study combining vending machine and garbage bin concepts — alerting authorities when full, tracking user activity. Closest local parallel.

Arduino Ballpoint Pen Vending Machine — Plastic Bottle Exchange

Boto et al. (2023)

Philippine study showing high user satisfaction when Arduino dispenses school supplies in exchange for empty plastic bottles — confirms reward-based acceptance.

Republic Act No. 11898 — Extended Producer Responsibility Act

Philippine Government (2022)

Provides legal foundation for the project. The proposed machine directly supports RA 11898's goals of plastic waste recovery and community recycling.