AI-Powered Smart Waste Sorting and Management System

Raspberry Pi 5 Inference Engine: YOLO11n NCNN On-Device Waste Classification, Google Colab Training Pipeline, and Python State-Machine Controller

Category: AI / Machine Learning, Computer Vision, Single-Board Computers, Embedded AI
Tools & Technologies: Raspberry Pi 5 (4 GB), Pi Camera Module v2, YOLO11n (Ultralytics), NCNN (Tencent), Google Colab (T4 GPU), Python 3.11, picamera2, pyserial, systemd

Status: Completed  |  Phase 11, May 2026

AI-Powered Smart Waste Sorting and Management System
This page covers the Raspberry Pi 5 AI engine. The ESP32 hardware controller (servo sorting, ultrasonic sensors, SIM800L GSM alerts, and I2C LCD dashboard) is documented on the Embedded Systems companion page.

Project Overview

This is the AI brain of a two-processor waste sorting system. A Raspberry Pi 5 runs a custom-trained YOLO11n NCNN model that classifies waste items deposited into the bin as either Recyclable (CARDBOARD, GLASS, METAL, PAPER, PLASTIC) or Non-Recyclable (BIODEGRADABLE). The classification result is sent to an ESP32 over UART, which then physically sorts the waste using servo motors.

The Pi runs continuously in a Python state machine that waits for a SCAN trigger from the ESP32, captures live frames with picamera2, runs NCNN inference, votes across multiple frames over a 5-second stabilisation window, then transmits the majority result back to the ESP32. The YOLO11n nano model was converted to NCNN for on-device ARM optimisation, achieving 2–3× faster inference than PyTorch on the Pi 5 without any GPU.

67.96%
Overall mAP50
6
Waste Classes
10,464
Training Images
50
Training Epochs
YOLO11n
Base Model (Nano)
100%
Group Accuracy (4/4)

Hardware: Raspberry Pi 5 Setup

Component Details
Single-Board Computer Raspberry Pi 5, 4 GB RAM, Broadcom BCM2712 (quad-core Cortex-A76, 2.4 GHz)
Camera Pi Camera Module v2, 8 MP Sony IMX219 sensor, CSI-2 interface
Operating System Raspberry Pi OS Trixie (Debian 13, 64-bit)
UART Serial GPIO 14 (TX) / GPIO 15 (RX), connected to ESP32 GPIO 16 / 17 at 115200 baud
Cooling Active cooler recommended, NCNN inference generates sustained CPU load
Power Pi 5 requires USB-C PD 5V/5A (27W) for stable operation under load
UART configuration on Pi 5
Two steps are required to enable hardware UART on GPIO 14/15. First, add enable_uart=1 to /boot/firmware/config.txt. Second, run sudo raspi-config → Interface Options → Serial Port → No (login shell) → Yes (hardware) → reboot. The second step disables the getty process that would otherwise echo every byte received from the ESP32 back onto the TX line, creating a UART feedback loop.

Pi 5 note: do not add dtoverlay=disable-bt. On Pi 5, Bluetooth uses a completely separate internal path and does not share GPIO 14/15. That overlay is only required on Pi 4 and earlier.

Circuit Diagram

Full Proteus circuit diagram showing the complete wiring of both subsystems: the ESP32 embedded controller (sensors, servo, GSM, display, power) and the Raspberry Pi 5 inference engine (UART link, camera, power supply).

Full colour Proteus circuit diagram showing all components and wiring for the Smart Waste Management System
Full colour Proteus circuit diagram showing all components and wiring for the Smart Waste Management System
Black-and-white Proteus circuit diagram, alternative view with clearer trace routing
Black-and-white Proteus circuit diagram, alternative view with clearer trace routing

Dataset: GARBAGE CLASSIFICATION 3

The model was trained on the GARBAGE CLASSIFICATION 3 dataset sourced from Roboflow, containing 10,464 labelled images across 6 waste categories.

Split Images Share
Train 7,908 75.6%
Validation 1,776 17.0%
Test 780 7.4%
Total 10,464 100%

Classes: BIODEGRADABLE, CARDBOARD, GLASS, METAL, PAPER, PLASTIC. Roboflow augmentations applied: horizontal flip, random crop, brightness/contrast jitter (hue/saturation were left unchanged to preserve colour as a classification signal).

Dataset split note: The Roboflow export placed all 10,464 images into train/ with no valid/ or test/ split. The training notebook includes a pre-training auto-split cell that moves 20% of images to valid/ and 10% to test/ before YOLO training begins. Without this step, validation loss cannot be computed and the best checkpoint cannot be selected during training.


Training Pipeline

  1. Roboflow: 10,464 labelled images across 6 classes, downloaded in YOLOv11 format
  2. Google Colab (T4 GPU): YOLO11n trained for 50 epochs at imgsz 320 (~1 hour)
  3. best.pt: PyTorch checkpoint saved from the best validation epoch
  4. NCNN export: YOLO('best.pt').export(format='ncnn', imgsz=320) via Ultralytics — do not add half=True; Pi 5 has no FP16 hardware accelerator, so half-precision either slows inference or causes arithmetic errors on the Cortex-A76
  5. Raspberry Pi 5: NCNN model files copied to Pi for on-device inference
Training Parameter Value
Base model YOLO11n (nano, 2.9M parameters)
Framework Ultralytics YOLO 8.3.x
Training environment Google Colab, T4 GPU (16 GB VRAM)
Epochs 50 (early stopping disabled)
Image size 320 × 320 px
Batch size 32
Confidence threshold (inference) 0.50
Training duration 1.062 hours (3,823 seconds)
Export format NCNN (Tencent) for ARM CPU inference

Why NCNN instead of PyTorch or ONNX?

NCNN is a neural network inference framework developed by Tencent specifically for mobile and embedded ARM processors. On the Raspberry Pi 5 ARM Cortex-A76 CPU, NCNN achieves 2–3× faster inference than raw PyTorch .pt due to NEON SIMD vectorisation and Winograd convolution optimisation. OpenVINO was not used because it targets Intel hardware. TensorRT requires Nvidia GPU. NCNN is the correct tool for this platform.

Critical Python library install pitfall
pip install ultralytics on Raspberry Pi 5 will attempt to install PyTorch with CUDA support, which fails silently or conflicts with ARM packages. The correct install sequence for Raspberry Pi OS (64-bit) is:

sudo apt install python3-picamera2 (camera library, must use apt not pip)
pip install torch --index-url https://download.pytorch.org/whl/cpu --no-deps --break-system-packages
pip install ultralytics --no-deps --break-system-packages
pip install ultralytics-thop --no-deps --break-system-packages
pip install pyserial --break-system-packages

The --no-deps flag is critical on every PyTorch-related package. Without it, pip resolves the full CUDA dependency tree and attempts to download approximately 1.5 GB of NVIDIA libraries that do not exist for ARM and will crash or corrupt the environment. The NCNN runtime itself does not need PyTorch; torch is only used on Colab during the export step.

Model Performance

Evaluated on the held-out test set (780 images) using YOLO11n NCNN with confidence threshold 0.50 and IoU threshold 0.50 (mAP50).

Per-Class mAP50

GLASS
82.5%
PAPER
72.2%
METAL
71.8%
PLASTIC
61.4%
BIODEGRADABLE
60.8%
CARDBOARD
59.3%
Overall mAP50
67.96%

Why Group Accuracy Matters More Than Per-Class mAP50

The system does not need to identify the exact waste material. It only needs to decide Recyclable (R) or Non-Recyclable (N). An item correctly identified as PLASTIC (Recyclable) when the ground-truth label is GLASS (also Recyclable) is a per-class "miss" but a correct sort. In real-world testing across 4 trials, the system achieved 4/4 (100%) correct group-level sorting.

Classification group mapping
Recyclable (R): CARDBOARD · GLASS · METAL · PAPER · PLASTIC
Non-Recyclable (N): BIODEGRADABLE

Training Metrics & Visualisations


Python Detection State Machine

trash_sorter.py runs a four-state machine. The Pi Camera captures frames continuously, but YOLO inference only runs in SCANNING and STABILIZING. It is skipped entirely in WAITING and RESTING to reduce CPU temperature and power draw.

State flow: WAITINGSCANNINGSTABILIZINGRESTINGWAITING

State YOLO running? Enters when Exits when Action on exit
WAITING No Boot complete, or RESTING timer expires ESP32 sends SCAN\n Clear vote list, begin SCANNING
SCANNING Yes SCAN received from ESP32 Any frame detects an object at ≥ 0.50 confidence Record timestamp, start vote list → STABILIZING
STABILIZING Yes First detection in SCANNING 5 s elapsed with object present,
OR object lost mid-countdown
5 s complete: majority vote → send R\n or N\n → RESTING.
Object lost: clear votes → back to SCANNING (no signal sent).
RESTING No Result transmitted at end of STABILIZING 5 s cooldown elapses Return to WAITING; next cycle waits for next SCAN
The UART signal is sent at the end of STABILIZING, not in RESTING.
RESTING is a pure cooldown state. Once R or N has been transmitted, the ESP32 immediately starts servo actuation. The Pi's 5-second rest window exists solely to prevent a second SCAN from being accepted while the physical sort is still in progress. The result is transmitted the instant the 5-second majority-vote window closes — that is the final moment of STABILIZING, not the start of RESTING.

If the item slides out of frame or tips over during the STABILIZING countdown, the state resets to SCANNING with the vote list cleared and no signal sent. The 5-second window restarts cleanly the moment the object is re-detected above the confidence threshold. This prevents any partial or ambiguous vote from producing a sort result.

The 5-second STABILIZE window (increased from 2.5 s during development) was confirmed necessary after testing revealed that the first 1–2 seconds of detection can be dominated by a side-angle view of the item as it drops and settles, which skews the vote toward the wrong class. The longer window gives the item time to come to rest in a face-on orientation before the majority is computed.


Python Code: Key Excerpts

The full source is available on GitHub. These are the most architecturally significant sections of trash_sorter.py.

1. NCNN Model Inference on a Camera Frame

from ultralytics import YOLO
from picamera2 import Picamera2
import numpy as np

# Load NCNN model (converted from best.pt on Colab)
model = YOLO("best_ncnn_model/", task="detect")

# picamera2 setup — fixed resolution for NCNN imgsz=320
picam2 = Picamera2()
config = picam2.create_preview_configuration(
    main={"size": (640, 480), "format": "RGB888"}
)
picam2.configure(config)
picam2.start()

def classify_frame() -> str | None:
    """
    Capture one frame and return the highest-confidence class name,
    or None if no detection exceeds the confidence threshold (0.50).
    """
    frame = picam2.capture_array()          # BGR numpy array
    results = model(frame, conf=0.50, verbose=False)

    best_cls  = None
    best_conf = 0.0
    for box in results[0].boxes:
        cls_id = int(box.cls[0])
        conf   = float(box.conf[0])
        if conf > best_conf:
            best_conf = conf
            best_cls  = model.names[cls_id]  # e.g. "GLASS"

    return best_cls   # None if nothing detected above threshold

2. State Machine Main Loop

The condensed logic below shows how SCANNING and STABILIZING are separate states, and where the UART signal is actually transmitted.

import serial, time

ser = serial.Serial("/dev/ttyAMA0", baudrate=115200, timeout=0)

STABILIZE_SEC = 5.0    # hold the item for this long before sending result
REST_SECONDS  = 5      # post-sort cooldown; no new SCAN accepted
CONF_THRESH   = 0.50   # frames below this confidence do not count

RECYCLABLE = {"CARDBOARD", "GLASS", "METAL", "PAPER", "PLASTIC"}

STATE_WAITING     = "WAITING"
STATE_SCANNING    = "SCANNING"
STATE_STABILIZING = "STABILIZING"
STATE_RESTING     = "RESTING"

state        = STATE_WAITING
stable_start = None
stable_votes = []
rest_end     = None

while True:
    # Non-blocking UART read — checked every frame regardless of state
    incoming = ""
    if ser.in_waiting > 0:
        incoming = ser.read(ser.in_waiting).decode("utf-8", errors="ignore").strip()

    frame_bgr = picam2.capture_array()  # Pi Camera v2 delivers BGR bytes

    # ── WAITING: YOLO is OFF; only listening for SCAN ────────────────────
    if state == STATE_WAITING:
        if incoming == "SCAN":
            state = STATE_SCANNING
        # frame captured but NOT passed to model

    else:
        # ── Run YOLO inference (SCANNING and STABILIZING only) ────────────
        results = model(frame_bgr, imgsz=320, conf=CONF_THRESH, verbose=False)
        detected_label = None
        for r in results:
            for box in r.boxes:
                detected_label = model.names[int(box.cls[0])]

        # ── SCANNING: wait for the first detection ────────────────────────
        if state == STATE_SCANNING:
            if detected_label:
                state        = STATE_STABILIZING
                stable_start = time.time()
                stable_votes = [detected_label]

        # ── STABILIZING: accumulate votes for 5 s ────────────────────────
        elif state == STATE_STABILIZING:
            if detected_label:
                stable_votes.append(detected_label)
                elapsed = time.time() - stable_start
                if elapsed >= STABILIZE_SEC:
                    # Majority vote → send signal → RESTING
                    final  = max(set(stable_votes), key=stable_votes.count)
                    signal = b"R\n" if final in RECYCLABLE else b"N\n"
                    ser.write(signal)          # signal sent here, end of STABILIZING
                    ser.flush()
                    state    = STATE_RESTING
                    rest_end = time.time() + REST_SECONDS
                    stable_votes = []
            else:
                # Object lost before countdown finished — no signal sent
                state        = STATE_SCANNING
                stable_votes = []
                stable_start = None

        # ── RESTING: cooldown only; no classification, no signals ─────────
        elif state == STATE_RESTING:
            if time.time() >= rest_end:
                state    = STATE_WAITING
                rest_end = None

3. systemd Service for Autostart (Phase 11)

The Pi script starts automatically on boot via a systemd unit. The service uses Restart=on-failure so the detector restarts after unexpected crashes but does not loop endlessly after a deliberate stop.

SHOW_PREVIEW must be False for autostart
When the systemd service runs at boot, no desktop session exists yet. Any call to cv2.imshow() will immediately raise a cv2.error: (-215) !_src.empty() and crash the service. The variable SHOW_PREVIEW = False must be set in trash_sorter.py before deploying the systemd service. Preview mode is only useful during interactive development sessions.
# /etc/systemd/system/trash-sorter.service

[Unit]
Description=Trash Sorter AI Detection System
After=multi-user.target

[Service]
Type=simple
User=adegoke
WorkingDirectory=/home/adegoke/trash_project
ExecStart=/usr/bin/python3 /home/adegoke/trash_project/trash_sorter.py
Restart=on-failure
RestartSec=5
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

# sudo systemctl daemon-reload
# sudo systemctl enable trash-sorter.service
# sudo systemctl start  trash-sorter.service
# sudo journalctl -fu   trash-sorter.service  (live logs)
Phase 11 complete, Autostart confirmed
The systemd autostart was validated on May 15, 2026. The Pi boots, the detector starts without any manual intervention, the ESP32 receives the READY handshake within 20 seconds of Pi power-on, and waste sorting proceeds normally.

Engineering Challenges & Solutions

Ten real hardware and software engineering challenges were solved during development. Each solution directly shaped the final system architecture.

View all 10 engineering challenges & solutions

Challenge 1: Ultrasonic False Positives ("Falling Dirt")

A piece of waste falling through the air momentarily reflects sound waves, making the bin appear full before it lands. The fix was an Obstruction Verification Delay: the ESP32 sets a flag and starts a millis() timer. Only if the reading stays below FULL_THRESHOLD continuously for 4.5 seconds is the bin officially locked. Transient reflections clear themselves.

Challenge 2: Horizontal "Tripwire" Sensor Orientation

Downward-pointing sensors produce inaccurate fill levels because waste piles unevenly (a bottle standing upright in the centre triggers a false "full" while 90% of the space is empty). Mounting sensors horizontally across the brim turns them into a tripwire: any reading below 16 cm means the horizontal beam is physically blocked, which only happens when the bin is actually full.

Challenge 3: AI Serial Spamming and Buffer Overloads

At 30 fps, the Pi would send 30 classification signals per second, flooding the ESP32 serial buffer and causing the servo to repeat its sweep until the system crashed. The solution was a Handshake & Cooldown Protocol: after sending one R\n or N\n, the Pi enters a 5-second STATE_RESTING. On the ESP32 side, immediately after executing the mechanical sweep, a buffer flush loop reads and discards any stale serial bytes before accepting the next command.

Challenge 4: Raspberry Pi 5 Power Throttling

The Pi 5 displayed a lightning-bolt low-voltage warning; vcgencmd get_throttled returned 0xd0000, confirming active CPU throttling. The fix involved three steps: replacing thin jumper wires with high-gauge copper wire to lower resistance; tuning the XL4016 300W DC-DC buck converter to output 5.39–5.40 V (a deliberate over-voltage to compensate for remaining wire drop under load); and turning the current potentiometer to maximum to keep the module in Constant Voltage (green LED) mode. Stress-tested with stress -c 4 -t 60 achieving throttled=0x0.

Challenge 5: Servo Jitter and "Hunting"

The sorting servo buzzed and shook continuously when holding the centre position because the ESP32's PWM signal made the servo motor micro-correct against gravity indefinitely. A "Quiet Mode" (Detach Logic) was implemented: moveAndDetach() attaches the servo, sweeps it to the target angle, waits 200 ms for physical arrival, then calls sortServo.detach() to cut the PWM signal entirely. The top-cover servo intentionally retains continuous attachment to maintain holding torque.

Challenge 6: Top Cover Directional Mismatch

Due to how the servo horn was physically mounted, the expected open/close directions were reversed and the original per-trash-item actuation was slow and awkward. The redesign redefined 0° = OPEN, 90° = CLOSED and repurposed the cover as a System Lockout Hatch: permanently open during normal operation, closing only when a bin is full. Smooth actuation functions (openTopCover() / closeTopCover()) use 15 ms per-degree delays to prevent violent jerks.

Challenge 7: Phantom AI Detections and CPU Heat

Running YOLO continuously at 30 fps while the bin was idle caused the Pi to run hot and risk "phantom" detections (e.g., a blue shirt triggering "Plastic"). A third ultrasonic sensor in the deposit compartment solved this: when a user's hand is detected (<25 cm), the ESP32 waits 4 seconds for the hand to leave and the item to stop wobbling, then sends a single SCAN\n UART command. The Pi's 5-state machine keeps YOLO completely bypassed in WAITING and RESTING states, running inference only during SCANNING and STABILIZING.

Challenge 8: Non-Blocking ESP32 Serial Reads

Serial2.readStringUntil('\n') is a blocking call: a malformed message without a newline would freeze the entire ESP32 loop() for 1,000 ms, causing sensor misses and an unresponsive button. The fix was a single line in setup(): Serial2.setTimeout(50);. This caps the blocking wait at 50 ms, keeping the main loop effectively real-time.

Challenge 9: Boot-Time Handshake and Screen Synchronisation

The ESP32 boots in ~1 second; the Pi takes ~30 seconds to load the OS, Python, the NCNN model, and the camera. Without synchronisation, the ESP32 had no way to know when the AI was actually ready. The Pi script sends READY\n the moment initialisation completes, followed by WIFI_OK\n or WIFI_NO\n after pinging Google DNS. The ESP32 catches these signals and advances the LCD through a multi-stage splash screen, finally settling on "Waiting for waste..".

Challenge 10: Bin-Reset State Management (The Push Button)

Even after a janitor empties a full bin, the sensor instantly reads clear. If the code unlocked automatically, any debris falling over could trigger infinite lock/unlock loops. The design requires manual acknowledgment: leftBinLocked stays true until the janitor presses the physical push button (Pin 13). A 50 ms debounce filter ensures clean presses. On press, all lock booleans and SMS flags are reset, the buzzer beeps once to confirm, and the top cover sweeps open.


System Photos

Full build documentation from component procurement to the completed, live-running system.

Components and Procurement

Raspberry Pi 5 (4 GB) board laid flat, showing the BCM2712 chip, GPIO header, USB ports and the Raspberry Pi logo
Raspberry Pi 5 (4 GB) board laid flat, showing the BCM2712 chip, GPIO header, USB ports and the Raspberry Pi logo
SanDisk 64 GB microSD card still in its packaging, the storage medium for the Pi's operating system
SanDisk 64 GB microSD card still in its packaging, the storage medium for the Pi's operating system
Overview of delivered components: the Bona DC 12V 50W solar panel box, the solar charge controller box and the VINTAGE battery box, before unpacking
Overview of delivered components: the Bona DC 12V 50W solar panel box, the solar charge controller box and the VINTAGE battery box, before unpacking
Dencity Solar Charge Controller with LCD display, MCU control buttons, USB output ports and six screw terminals
Dencity Solar Charge Controller with LCD display, MCU control buttons, USB output ports and six screw terminals
Pi Camera Module v2 lying flat with its orange CSI ribbon cable attached, showing the lens, red LED and PCB labeling
Pi Camera Module v2 lying flat with its orange CSI ribbon cable attached, showing the lens, red LED and PCB labeling
Side view of the VINTAGE VT18-12 battery box showing the blue VINTAGE branding on the top face
Side view of the VINTAGE VT18-12 battery box showing the blue VINTAGE branding on the top face
VINTAGE VT18-12 Gel Deep Cycle Battery in its opened box, the 12 V 18 Ah battery that powers the whole system
VINTAGE VT18-12 Gel Deep Cycle Battery in its opened box, the 12 V 18 Ah battery that powers the whole system
VINTAGE VT18-12 Gel Deep Cycle Battery out of its box showing the front face with all spec labels including 12 V, 18 Ah and voltage ratings
VINTAGE VT18-12 Gel Deep Cycle Battery out of its box showing the front face with all spec labels including 12 V, 18 Ah and voltage ratings
VINTAGE VT18-12 battery from a side angle showing the spec label, caution notice and Wellbun Korea branding
VINTAGE VT18-12 battery from a side angle showing the spec label, caution notice and Wellbun Korea branding
SIM800L GSM module (blue EVB board) with its external whip antenna connected via a u.FL coaxial pigtail, the component that sends SMS alerts
SIM800L GSM module (blue EVB board) with its external whip antenna connected via a u.FL coaxial pigtail, the component that sends SMS alerts
DC-DC buck converter module inside an anti-static protective bag as received during delivery
DC-DC buck converter module inside an anti-static protective bag as received during delivery
DC-DC buck converter with large toroidal inductor, multiple capacitors, blue screw terminal blocks and heatsink fins on both sides
DC-DC buck converter with large toroidal inductor, multiple capacitors, blue screw terminal blocks and heatsink fins on both sides
CJY brushless DC cooling fan, 12 V 0.20 A, with two-wire connector, used for enclosure ventilation
CJY brushless DC cooling fan, 12 V 0.20 A, with two-wire connector, used for enclosure ventilation
Two electronic modules in their delivery packaging: one in a red bubble-wrap protective pouch and one in a silver anti-static bag
Two electronic modules in their delivery packaging: one in a red bubble-wrap protective pouch and one in a silver anti-static bag
20x4 character LCD display with yellow-green backlight alongside its separate I2C backpack module, before soldering
20x4 character LCD display with yellow-green backlight alongside its separate I2C backpack module, before soldering
Four female GPIO pin-header socket strips laid out, used for socketed connections on the circuit board
Four female GPIO pin-header socket strips laid out, used for socketed connections on the circuit board
Large perfboard showing the grid of drilled holes, used as the base for the circuit assembly
Large perfboard showing the grid of drilled holes, used as the base for the circuit assembly
Five 220 ohm metal-film resistors held between two cardboard strips with the value handwritten as 220 ohm, used as LED current limiters
Five 220 ohm metal-film resistors held between two cardboard strips with the value handwritten as 220 ohm, used as LED current limiters
Mini rocker switch from the front showing the O/— on-off symbols and two connection pins
Mini rocker switch from the front showing the O/— on-off symbols and two connection pins
The same mini rocker switch from the back showing the CE and CCC certification marks and the two wiring pins
The same mini rocker switch from the back showing the CE and CCC certification marks and the two wiring pins
Two HC-SR04 ultrasonic distance sensors stacked one above the other, both showing the twin transducer eyes and HC-SR04 label
Two HC-SR04 ultrasonic distance sensors stacked one above the other, both showing the twin transducer eyes and HC-SR04 label
ESP32 DevKit board on a flat surface, showing the antenna, USB port and row of GPIO pins
ESP32 DevKit board on a flat surface, showing the antenna, USB port and row of GPIO pins
MG995 metal-gear servo motor with its complete set of servo horn accessories (cross disc, round disc, single arm, screws and grommets)
MG995 metal-gear servo motor with its complete set of servo horn accessories (cross disc, round disc, single arm, screws and grommets)
Six through-hole LEDs laid out: two red, two yellow and two green, used as status indicator lights
Six through-hole LEDs laid out: two red, two yellow and two green, used as status indicator lights
WEIYIXING 3007S brushless DC fan, 5 V 0.16 A, with three-wire connector, used for electronics cooling
WEIYIXING 3007S brushless DC fan, 5 V 0.16 A, with three-wire connector, used for electronics cooling
Bundle of multicolour male-to-female jumper wires (Dupont cables) used for prototyping connections
Bundle of multicolour male-to-female jumper wires (Dupont cables) used for prototyping connections
A coil of black heat shrink tubing used to insulate and protect wire connections throughout the build
A coil of black heat shrink tubing used to insulate and protect wire connections throughout the build
Kaina solder wire reel, 63/37 tin-lead alloy, 0.8 mm diameter, CF-10 flux 2.0%, used for all the soldering work on the project
Kaina solder wire reel, 63/37 tin-lead alloy, 0.8 mm diameter, CF-10 flux 2.0%, used for all the soldering work on the project
Flat ribbon cable coiled loosely, white with a blue stripe, used for internal signal wiring connections
Flat ribbon cable coiled loosely, white with a blue stripe, used for internal signal wiring connections
A coil of thick red and black silicone power wires, used for the high-current battery connections
A coil of thick red and black silicone power wires, used for the high-current battery connections
The 50 W Bona solar panel propped upright against a wall, showing its full face and the cable coiled at the base
The 50 W Bona solar panel propped upright against a wall, showing its full face and the cable coiled at the base
50 W Bona solar panel standing upright against a wall, front face showing the cell grid and aluminium frame, with cable on the floor
50 W Bona solar panel standing upright against a wall, front face showing the cell grid and aluminium frame, with cable on the floor
Close-up of the Bona AP-PM-50 solar panel spec label: 50 W maximum power, Vmp 19.32 V, Voc 23.18 V, Isc 2.78 A, with junction box connector above
Close-up of the Bona AP-PM-50 solar panel spec label: 50 W maximum power, Vmp 19.32 V, Voc 23.18 V, Isc 2.78 A, with junction box connector above

Early Electronics Prototyping

ESP32 placed on a perfboard at the very start of prototyping, with solder wire nearby but no connections yet made
ESP32 placed on a perfboard at the very start of prototyping, with solder wire nearby but no connections yet made
Wider view of the perfboard with the ESP32 positioned at the top and a pin header strip along the left edge, before any wiring
Wider view of the perfboard with the ESP32 positioned at the top and a pin header strip along the left edge, before any wiring
The back of the 20x4 LCD showing the I2C PCB module soldered on and the four-wire connector pigtail
The back of the 20x4 LCD showing the I2C PCB module soldered on and the four-wire connector pigtail
Solar panel, 12 V battery and the charge controller connected together outdoors for a first power test
Solar panel, 12 V battery and the charge controller connected together outdoors for a first power test
Wider shot of the same outdoor power-system test showing the panel, battery and controller wired up on the ground
Wider shot of the same outdoor power-system test showing the panel, battery and controller wired up on the ground
Builder at the work desk with components spread across the surface, in the middle of an early wiring session
Builder at the work desk with components spread across the surface, in the middle of an early wiring session
Top-down view of the outdoor power-system test with the solar panel, battery, charge controller and additional electronics on the ground
Top-down view of the outdoor power-system test with the solar panel, battery, charge controller and additional electronics on the ground
Raspberry Pi 5 with a small blower fan placed on the processor and the Pi Camera Module with ribbon cable laid alongside, before final assembly
Raspberry Pi 5 with a small blower fan placed on the processor and the Pi Camera Module with ribbon cable laid alongside, before final assembly
Angled front view of the Pi 5 with the blower fan and the camera ribbon cable arching over the board, showing the HDMI port and GPIO header
Angled front view of the Pi 5 with the blower fan and the camera ribbon cable arching over the board, showing the HDMI port and GPIO header
Pi Camera Module held up in a hand connected via ribbon cable to the Pi 5 below, showing the lens and the assembled system together
Pi Camera Module held up in a hand connected via ribbon cable to the Pi 5 below, showing the lens and the assembled system together
Angled top view of the Pi 5 board showing the blower fan, chip area, GPIO header and the Raspberry Pi 5 label, with the camera ribbon visible at the edge
Angled top view of the Pi 5 board showing the blower fan, chip area, GPIO header and the Raspberry Pi 5 label, with the camera ribbon visible at the edge
Pi 5 with the camera ribbon cable plugged into the CSI port, confirming the physical connection before software testing
Pi 5 with the camera ribbon cable plugged into the CSI port, confirming the physical connection before software testing

Enclosure Construction

Two corrugated side panels propped together on the ground during construction, with a jerry can used as a weight and a power drill nearby
Two corrugated side panels propped together on the ground during construction, with a jerry can used as a weight and a power drill nearby
The bin frame on four castor wheels with corrugated side panels and an orange front panel already fitted, photographed from a low angle outdoors
The bin frame on four castor wheels with corrugated side panels and an orange front panel already fitted, photographed from a low angle outdoors
The bin body shell under construction showing the corrugated side and back panels joined with wooden framing, with a drill inside, photographed from above
The bin body shell under construction showing the corrugated side and back panels joined with wooden framing, with a drill inside, photographed from above
Top-down view into the open bin showing the central divider panel creating two compartments, with metal mounting brackets on the interior walls
Top-down view into the open bin showing the central divider panel creating two compartments, with metal mounting brackets on the interior walls
Three-quarter angled view of the bin with the front panel not yet fitted, revealing the interior compartment divider and a lower opening, with tools on the ground
Three-quarter angled view of the bin with the front panel not yet fitted, revealing the interior compartment divider and a lower opening, with tools on the ground
Elevated angled view of the bin showing the two upper sorting compartments open at the top and the structural framing at the front, with a drill on the ground
Elevated angled view of the bin showing the two upper sorting compartments open at the top and the structural framing at the front, with a drill on the ground
Three-quarter angled view of the bin showing the upper sorting section and the lower open storage bay, with corrugated panel walls and wooden framing
Three-quarter angled view of the bin showing the upper sorting section and the lower open storage bay, with corrugated panel walls and wooden framing
Elevated front view of the bin under construction without its top panel, showing the two upper sorting compartments and the lower open bay
Elevated front view of the bin under construction without its top panel, showing the two upper sorting compartments and the lower open bay
The bin frame tipped at a steep angle outdoors on its caster wheels, showing the corrugated side panels and the open interior from the side
The bin frame tipped at a steep angle outdoors on its caster wheels, showing the corrugated side panels and the open interior from the side
Angled front view of the bin showing the two upper sorting compartments with plywood floors and the lower open bay, with the right side panel partially open
Angled front view of the bin showing the two upper sorting compartments with plywood floors and the lower open bay, with the right side panel partially open
Elevated view of the bin with a rectangular opening cut into the front upper panel, marked with green measurement annotations, and the two sorting compartments visible at the top
Elevated view of the bin with a rectangular opening cut into the front upper panel, marked with green measurement annotations, and the two sorting compartments visible at the top
Angled exterior view of the bin showing the two upper compartments open at the top, the rectangular front opening, and the lower bay
Angled exterior view of the bin showing the two upper compartments open at the top, the rectangular front opening, and the lower bay
Top-down view into the open bin showing three side-by-side sorting compartments separated by two internal dividers
Top-down view into the open bin showing three side-by-side sorting compartments separated by two internal dividers
Angled view of the bin front face showing the large rectangular camera cutout opening, with the two upper compartments visible at the top
Angled view of the bin front face showing the large rectangular camera cutout opening, with the two upper compartments visible at the top
Front view of the bin exterior showing the large rectangular cutout on the front panel marked with green measurement lines, with the open top compartments visible above
Front view of the bin exterior showing the large rectangular cutout on the front panel marked with green measurement lines, with the open top compartments visible above
Three-quarter angled exterior view of the bin showing the rectangular cutout on the front panel and a black-painted panel beginning to appear at the top
Three-quarter angled exterior view of the bin showing the rectangular cutout on the front panel and a black-painted panel beginning to appear at the top
A narrow wooden strip held in a hand showing a small hole drilled through it, used as a bracket or mounting piece for a sensor
A narrow wooden strip held in a hand showing a small hole drilled through it, used as a bracket or mounting piece for a sensor
The sorting divider flap painted black, the surface that the servo will pivot left and right to direct waste
The sorting divider flap painted black, the surface that the servo will pivot left and right to direct waste
Elevated view of the bin flipped upside down, showing the four castor wheel brackets mounted on the base panel, with the interior visible through the open front
Elevated view of the bin flipped upside down, showing the four castor wheel brackets mounted on the base panel, with the interior visible through the open front

Control Panel Fabrication

Charge controller and the LCD placed on a cardboard surface during a bench test before panel installation
Charge controller and the LCD placed on a cardboard surface during a bench test before panel installation
Drilling holes into the panel board for the LCD, LEDs and button cutouts
Drilling holes into the panel board for the LCD, LEDs and button cutouts
Another angle of the panel drilling process, showing the drill bit going through the panel board
Another angle of the panel drilling process, showing the drill bit going through the panel board
Rocker switch fitted into its rectangular cutout in the panel, photographed from the front
Rocker switch fitted into its rectangular cutout in the panel, photographed from the front
The panel board mid-process with a rectangular slot already cut and a button trial-fitted, showing the green marker layout lines
The panel board mid-process with a rectangular slot already cut and a button trial-fitted, showing the green marker layout lines
Back side of the panel showing an LED indicator pushed through its mounting hole with wires attached, alongside a rectangular cutout
Back side of the panel showing an LED indicator pushed through its mounting hole with wires attached, alongside a rectangular cutout
The black acrylic front panel and the hardboard backing with the cooling fan already mounted, laid side by side before being joined together
The black acrylic front panel and the hardboard backing with the cooling fan already mounted, laid side by side before being joined together
The black acrylic panel with the cooling fan mounted and standoffs fitted, showing the hole layout with some components already installed
The black acrylic panel with the cooling fan mounted and standoffs fitted, showing the hole layout with some components already installed
Back side of the completed panel showing the cooling fan mounted and the wiring running from each component
Back side of the completed panel showing the cooling fan mounted and the wiring running from each component
Front of the panel with the charge controller unit fitted into its position
Front of the panel with the charge controller unit fitted into its position
Panel from the front with one of the LED indicators powered on, confirming the indicator is working
Panel from the front with one of the LED indicators powered on, confirming the indicator is working
Front face of the panel showing the LCD display, charge controller screen and the reset button together
Front face of the panel showing the LCD display, charge controller screen and the reset button together
Builder holding the fully assembled control panel, showing the front face with all components mounted and labelled
Builder holding the fully assembled control panel, showing the front face with all components mounted and labelled

Bin Assembly and Sensor Fitting

Two HC-SR04 ultrasonic sensor mounting holes in the bin wall, with the sensors inserted and viewed straight-on
Two HC-SR04 ultrasonic sensor mounting holes in the bin wall, with the sensors inserted and viewed straight-on
Drill driving screws into a hinge along the bin frame edge, with a second hinge already in place further along
Drill driving screws into a hinge along the bin frame edge, with a second hinge already in place further along
Side view of the bin wall showing the sensor holes from the outside of the enclosure
Side view of the bin wall showing the sensor holes from the outside of the enclosure
Multiple sensor holes drilled across the bin wall panels, showing the raw openings across two compartment faces
Multiple sensor holes drilled across the bin wall panels, showing the raw openings across two compartment faces
Orange jerry can cut near the base, with the top section held up and the shallow bottom tray section visible below, showing the open interior of both pieces
Orange jerry can cut near the base, with the top section held up and the shallow bottom tray section visible below, showing the open interior of both pieces
The cut jerry can pieces laid out, showing the sections that will be placed inside the compartments as liners
The cut jerry can pieces laid out, showing the sections that will be placed inside the compartments as liners
The top section of the cut jerry can viewed from the front, with a rectangular slot cut along the lower open edge for cable routing
The top section of the cut jerry can viewed from the front, with a rectangular slot cut along the lower open edge for cable routing
A slot cut into the side of a jerry can piece to allow sensor cables to pass through
A slot cut into the side of a jerry can piece to allow sensor cables to pass through
Inside the bin looking down, with the servo motor mounted at the top and two ultrasonic sensors visible on the walls
Inside the bin looking down, with the servo motor mounted at the top and two ultrasonic sensors visible on the walls
Top-down view into the bin interior showing the servo motor and an ultrasonic sensor mounted on the side wall, with the wooden divider panel visible
Top-down view into the bin interior showing the servo motor and an ultrasonic sensor mounted on the side wall, with the wooden divider panel visible
MG996 servo motor bolted to the ceiling of the sorting chamber, photographed from inside looking straight up at it
MG996 servo motor bolted to the ceiling of the sorting chamber, photographed from inside looking straight up at it
One of the bin compartments with the black-painted sorting flap visible inside
One of the bin compartments with the black-painted sorting flap visible inside
Straight-on view into the compartment showing the silver metallic sorting flap in its closed position, with the servo bracket visible at the top
Straight-on view into the compartment showing the silver metallic sorting flap in its closed position, with the servo bracket visible at the top
A plastic bottle placed on the sorting tray inside the bin as a test object, confirming the tray size is right
A plastic bottle placed on the sorting tray inside the bin as a test object, confirming the tray size is right
Builder crouching and reaching into the open top of the upright bin enclosure to fit internal components
Builder crouching and reaching into the open top of the upright bin enclosure to fit internal components
Builder leaning into the open electronics bay, running wires and making connections
Builder leaning into the open electronics bay, running wires and making connections
Closer shot of the builder with face visible while concentrating on the wiring work
Closer shot of the builder with face visible while concentrating on the wiring work
Printed label strips for the control panel, showing text including FAN, LAMP 1, LAMP 2, SOCKET, CHARGING STATUS, POWER SWITCH, PROGRAMMING PORT and ANTENNA
Printed label strips for the control panel, showing text including FAN, LAMP 1, LAMP 2, SOCKET, CHARGING STATUS, POWER SWITCH, PROGRAMMING PORT and ANTENNA

System Integration

First boot of the LCD on the finished control panel. It shows the custom startup message: Hello, Beuty! Coding has begun! Congratulations! Power By Deewansonic
First boot of the LCD on the finished control panel. It shows the custom startup message: Hello, Beuty! Coding has begun! Congratulations! Power By Deewansonic
The bin top cover with the hinges now glued and set, photographed from above to show the hinge line
The bin top cover with the hinges now glued and set, photographed from above to show the hinge line
Interior of the bin with white reflective lining applied to all inner walls, improving the camera lighting
Interior of the bin with white reflective lining applied to all inner walls, improving the camera lighting
The battery inside the base compartment of the bin enclosure, with power cables connected
The battery inside the base compartment of the bin enclosure, with power cables connected
The full electronics bay with every component wired up: ESP32, Pi, SIM800L, relay, charge controller and power rail
The full electronics bay with every component wired up: ESP32, Pi, SIM800L, relay, charge controller and power rail
Builder crouching outdoors while working on the open electronics bay of the bin, with tools and the solar panel laid flat on the ground around him
Builder crouching outdoors while working on the open electronics bay of the bin, with tools and the solar panel laid flat on the ground around him
Wide outdoor shot showing the full workshop scene with the bin sitting on the ground, the electronics bay exposed, the solar panel and tools scattered around
Wide outdoor shot showing the full workshop scene with the bin sitting on the ground, the electronics bay exposed, the solar panel and tools scattered around
Angled top-down view into the bin showing two ultrasonic sensors on the interior front wall, with the white-lined sorting tray and a marker pen visible below
Angled top-down view into the bin showing two ultrasonic sensors on the interior front wall, with the white-lined sorting tray and a marker pen visible below
Front-on view into the bin interior showing the ultrasonic sensors on the back wall, the white sorting tray panel, and the servo motor at the bottom right
Front-on view into the bin interior showing the ultrasonic sensors on the back wall, the white sorting tray panel, and the servo motor at the bottom right
Top-down view into the bin interior showing the sorting tray panel flat in its resting position, with the servo motor on the right wall and ultrasonic sensors on the far wall
Top-down view into the bin interior showing the sorting tray panel flat in its resting position, with the servo motor on the right wall and ultrasonic sensors on the far wall
Electronics bay photographed from the open side, showing the full wiring harness before cable management
Electronics bay photographed from the open side, showing the full wiring harness before cable management
Top-down view of the sorting chamber with sensors on the walls and the camera lens visible at the top
Top-down view of the sorting chamber with sensors on the walls and the camera lens visible at the top
Exterior view of the bin wall showing the Pi Camera PCB mounted in its cutout at the top, with the two HC-SR04 ultrasonic sensor barrels mounted below it
Exterior view of the bin wall showing the Pi Camera PCB mounted in its cutout at the top, with the two HC-SR04 ultrasonic sensor barrels mounted below it
View of the Pi Camera module mounted in its bracket at the top of the bin wall, angled downward to look into the sorting chamber
View of the Pi Camera module mounted in its bracket at the top of the bin wall, angled downward to look into the sorting chamber
Top-down interior view of the Pi Camera bracket mounted at the top rim of the bin, showing the camera PCB angled into the sorting chamber
Top-down interior view of the Pi Camera bracket mounted at the top rim of the bin, showing the camera PCB angled into the sorting chamber
Builder crouching beside the bin outdoors, working on the open electronics bay, with the solar panel on the ground in the foreground
Builder crouching beside the bin outdoors, working on the open electronics bay, with the solar panel on the ground in the foreground
Interior view showing the orange CSI ribbon cable connecting the Pi Camera module at the top of the bin down to the Raspberry Pi board mounted below
Interior view showing the orange CSI ribbon cable connecting the Pi Camera module at the top of the bin down to the Raspberry Pi board mounted below

Completed System and Live Testing

Front view of the assembled system outdoors showing the bin body, the open sorting chamber above with the interior light bulb on its frame, and the electronics panel face
Front view of the assembled system outdoors showing the bin body, the open sorting chamber above with the interior light bulb on its frame, and the electronics panel face
The integrated system with the solar panel mounted horizontally on the wooden overhead frame above the bin, showing the full physical assembly together
The integrated system with the solar panel mounted horizontally on the wooden overhead frame above the bin, showing the full physical assembly together
SIM800L module inside the electronics bay with the SIM card slot visible, confirming the GSM module is installed
SIM800L module inside the electronics bay with the SIM card slot visible, confirming the GSM module is installed
Full system view showing the bin, the overhead wooden frame, and the solar panel mounted flat on top, with the battery visible in the open electronics bay
Full system view showing the bin, the overhead wooden frame, and the solar panel mounted flat on top, with the battery visible in the open electronics bay
Builder standing next to the assembled system, steadying the solar panel already mounted on the overhead frame, with the electronics panel face visible at front
Builder standing next to the assembled system, steadying the solar panel already mounted on the overhead frame, with the electronics panel face visible at front
Front elevated view showing the top of the bin with marker annotations and the open electronics bay below, with the charge controller, LCD, fan and other components installed
Front elevated view showing the top of the bin with marker annotations and the open electronics bay below, with the charge controller, LCD, fan and other components installed
Front view of the enclosed bin showing the electronics panel with labels including CHARGE CONTROLLER, LCD, LEFT BIN FULL, WIFI, RIGHT BIN FULL, FAN and ALERT BUTTON
Front view of the enclosed bin showing the electronics panel with labels including CHARGE CONTROLLER, LCD, LEFT BIN FULL, WIFI, RIGHT BIN FULL, FAN and ALERT BUTTON
Side view of the bin on its wooden support frame, showing the overhead wooden frame structure above and the electronics panel at the front
Side view of the bin on its wooden support frame, showing the overhead wooden frame structure above and the electronics panel at the front
The black metal stand on its own, showing its rectangular frame construction with a central support column and base cross-brace
The black metal stand on its own, showing its rectangular frame construction with a central support column and base cross-brace
A green citrus fruit placed on the sorting tray inside the bin, used as the test organic waste item for classification
A green citrus fruit placed on the sorting tray inside the bin, used as the test organic waste item for classification
The interior lamp lit inside the sorting chamber during a demo run, with the green citrus fruit resting on the sorting tray
The interior lamp lit inside the sorting chamber during a demo run, with the green citrus fruit resting on the sorting tray
Builder standing beside the powered-on finished system, with the sorting chamber light visibly on and the electronics panel face showing
Builder standing beside the powered-on finished system, with the sorting chamber light visibly on and the electronics panel face showing

Video Demonstration

YouTube Demo, coming soon

A full walk-through of the AI classification pipeline and live sorting system will be uploaded to YouTube.


Project Links


Also see: ESP32 Hardware Controller Page
Covers the physical sorting mechanism: servo actuation, ultrasonic fill-level sensing, SIM800L GSM SMS alerts, 20×4 LCD dashboard, and the Arduino C++ deposit state machine. View ESP32 / Embedded Systems page →

Thank You for Visiting My Portfolio

I sincerely appreciate you taking the time to explore my portfolio and learn about my work and expertise. If you have any questions or wish to discuss potential collaborations, please feel free to reach out via the Contact section.

Best regards,
Damilare Lekan, Adekeye.