1. How It Works — 4-Stage Budget Edge-Vision Pipeline
Real-time object detection and physical sorting running completely on a microcontroller with 8 MB PSRAM.
IR Trigger & OV2640 Capture
When an e-waste item breaks the FC-51 IR proximity sensor beam (D2/GPIO3), the onboard OV2640 camera immediately snaps a crisp 96×96 frame directly into 8 MB PSRAM.
On-Device FOMO Object Detection
The dual-core ESP32-S3 runs a quantized FOMO (MobileNetV2 0.35) neural network locally in ~160 ms—detecting item centroids and class labels with zero cloud latency or GPU cost.
Dual-Servo Sorting & Hazard Interlock
Lithium-Ion batteries immediately swing Gate 1 (D0) into the fire-safe hazard bin while firing the Red LED & buzzer; PCBs/Cables divert via Gate 2 (D1); plastics pass straight through.
Wi-Fi MQTT Analytics
Every sorted object updates the local 0.96″ SSD1306 OLED and publishes live JSON telemetry (item class, confidence %, total hazards prevented) to a recycling facility dashboard.
2. Interactive Real Wiring Diagram (Seeed XIAO ESP32S3 Sense)
Filter each circuit group below to trace the external 5V 2A servo power rail, I2C OLED bus, IR trigger, and hazard alert bank.
D8–D10 remain free for the Sense board's onboard microSD slot.
Hardware Safety & Pinout Notes (Read Before Powering On)
- Never Power Servos from XIAO's 3V3 Pin: MG90S/SG90 servos draw 400–700 mA spikes when swinging. Always power them from an external 5V 2A DC supply tied to Common GND with a 470μF decoupling capacitor across 5V and GND to prevent ESP32-S3 brownout resets during camera capture.
- Keep D8–D10 Free for microSD Logging: On the Seeed XIAO ESP32S3 Sense expansion board, pins
D8 (GPIO7),D9 (GPIO8), andD10 (GPIO9)are shared with the onboard microSD card SPI bus. Keeping them free lets you save captured e-waste training photos straight to an SD card. - Power the FC-51 IR Sensor at 3.3V: The ESP32-S3 is strictly 3.3V logic. Powering the FC-51 IR proximity module from the XIAO
3V3pin guarantees its digitalOUTsignal never exceeds 3.3V onD2 (GPIO3).
3. Pin-to-Pin Wiring Table & Under-₹4,000 Bill of Materials
Complete pin mapping and realistic Indian-market component costs totaling ~₹3,150.
| Component | Module Pin | XIAO ESP32S3 Pin | ESP32-S3 GPIO | Function |
|---|---|---|---|---|
| Servo 1 (Battery Hazard) | SIG / VCC / GND | D0 / Ext 5V / GND |
GPIO1 |
Swings Gate 1 to divert Li-Ion batteries to Fire-Safe Bin |
| Servo 2 (PCB Recovery) | SIG / VCC / GND | D1 / Ext 5V / GND |
GPIO2 |
Swings Gate 2 to divert PCBs & Cables to Recovery Bin |
| FC-51 IR Proximity Sensor | OUT / VCC / GND | D2 / 3V3 / GND |
GPIO3 |
Active-LOW trigger when e-waste enters OV2640 camera zone |
| Active Piezo Buzzer | + (Pos) / − (Neg) | D3 / GND |
GPIO4 |
Audible fire-hazard alarm when a Lithium battery is spotted |
| 0.96" SSD1306 I2C OLED | SDA / SCL / VCC / GND | D4 / D5 / 3V3 / GND |
GPIO5 / GPIO6 |
Live status readout (Class, Confidence %, Inference ms, Counts) |
| Red Hazard LED (+220Ω) | Anode / Cathode | D6 / GND |
GPIO43 |
Flashes Red strobe on Lithium-Ion battery detection |
| Green Safe LED (+220Ω) | Anode / Cathode | D7 / GND |
GPIO44 |
Lights steady Green when sorting non-hazardous items |
| External 5V 2A + 470μF | +5V / GND | 5V / GND |
Power Bus | Clean high-current power rail for dual servos & XIAO board |
Under-₹4,000 Bill of Materials (Indian Market Pricing)
| Component | Recommended Part / Spec | Qty | Approx. Price (INR) |
|---|---|---|---|
| Edge-AI Vision Board | Seeed XIAO ESP32S3 Sense (OV2640 Cam + 8MB PSRAM + Mic) | 1 | ₹1,600 – ₹2,200 (avg ₹1,900) |
| Diverter Gate Servos | MG90S Metal-Gear (or SG90) Micro Servo Motors | 2 | ₹320 |
| Object Trigger Sensor | FC-51 Infrared Obstacle Avoidance Sensor Module | 1 | ₹60 |
| OLED Status Display | 0.96" I2C OLED Display (SSD1306, 128×64) | 1 | ₹220 |
| Servo Power & Filtering | 5V 2A DC Power Adapter + Barrel Jack + 470μF 16V Capacitor | 1 set | ₹250 |
| Hazard Alert Parts | Active Buzzer, Red/Green 5mm LEDs, 220Ω Resistors, Jumper Wires | 1 set | ₹150 |
| Mini Conveyor Structure | Cardboard / Foamboard Frame + Small DC Gear Motor Belt (or Ramp) | 1 set | ₹250 |
| Complete Build Cost (Well Under the ₹4,000 Student Budget!) | ~₹3,150 | ||
Other Under-₹4,000 Vision Boards from IoTInfo
Includes a dedicated KPU AI accelerator capable of ~15–20 FPS Tiny-YOLO, but has no built-in Wi-Fi and a smaller beginner community than ESP32-S3.
Runs full Linux + Python + OpenCV/TFLite, great for software students, though 512 MB RAM limits heavy models and SD card boot takes 25+ seconds.
Ultra-cheap option with OV2640, but requires an external FTDI USB programmer, has slower ESP32-D0WD CPU (no S3 AI vector instructions), and very few free GPIOs.
4. Interactive Live Conveyor & FOMO Vision Simulator
Drop e-waste items onto the moving conveyor belt to watch the IR trigger, Edge Impulse FOMO centroid detection, dual servo gates, and battery hazard interlock in action.
CONF: --% | INF: -- ms
TOTAL SORTED: 0
OFF
READY
5. 4-Step TinyML Vision Guide (Edge Impulse FOMO)
Train an accurate 4-class e-waste detector in your browser for free—no Python setup or cloud GPU required.
Capture 60–80 Photos Per Class
Mount the XIAO ESP32S3 Sense 15–20 cm above your conveyor belt under a steady white desk lamp. Capture 60–80 varied angles each of battery, pcb, cable, and plastic.
Label Bounding Boxes
Upload your images to Edge Impulse Studio (choose Object Detection project type). Draw tight bounding boxes around every e-waste object in the Labeling Queue—taking just 10 minutes.
Train FOMO (MobileNetV2 0.35)
Select FOMO (Faster Objects, More Objects) at 96×96 resolution. Unlike heavy YOLOv8 (which needs 100+ MB RAM), FOMO predicts object centroids using <250 KB RAM and runs smoothly at ~5 FPS on ESP32-S3.
Export & Flash with PSRAM
Go to Deployment → Arduino Library (.zip) (Int8 quantized). In Arduino IDE, select XIAO_ESP32S3, set Tools → PSRAM → OPI PSRAM, import the zip, and flash the starter sketch below.
6. Copy-Ready Arduino Starter Code (Seeed XIAO ESP32S3 Sense)
Install ESP32Servo and Adafruit SSD1306 from Library Manager, select XIAO_ESP32S3, enable OPI PSRAM, and upload.
// ============================================================================
// Vision-Based Automated E-Waste Sorter & Battery Hazard Detector (Under ₹4,000)
// Board: Seeed XIAO ESP32S3 Sense (Enable Tools -> PSRAM -> OPI PSRAM!)
// Pins: D0=Servo1(Hazard), D1=Servo2(PCB), D2=IR Trigger, D3=Buzzer,
// D4=OLED SDA, D5=OLED SCL, D6=Red Hazard LED, D7=Green Safe LED
// D8-D10 kept FREE for onboard microSD card slot.
// ============================================================================
#include "esp_camera.h"
#include <Wire.h>
#include <ESP32Servo.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// #include <your_ewaste_fomo_inferencing.h> // Uncomment after Edge Impulse export
// --- Seeed XIAO ESP32S3 Sense OV2640 Camera Pin Map ---
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 10
#define SIOD_GPIO_NUM 40
#define SIOC_GPIO_NUM 39
#define Y9_GPIO_NUM 48
#define Y8_GPIO_NUM 11
#define Y7_GPIO_NUM 12
#define Y6_GPIO_NUM 14
#define Y5_GPIO_NUM 16
#define Y4_GPIO_NUM 18
#define Y3_GPIO_NUM 17
#define Y2_GPIO_NUM 15
#define VSYNC_GPIO_NUM 38
#define HREF_GPIO_NUM 47
#define PCLK_GPIO_NUM 13
// --- External Actuator, Sensor & Alert Pins ---
#define SERVO_HAZARD_PIN D0 // GPIO1: Battery Hazard Diverter Gate 1
#define SERVO_PCB_PIN D1 // GPIO2: PCB/Cable Recovery Gate 2
#define IR_TRIGGER_PIN D2 // GPIO3: FC-51 IR Sensor (Active LOW)
#define BUZZER_PIN D3 // GPIO4: Active Piezo Buzzer
#define RED_LED_PIN D6 // GPIO43: Red Hazard LED (+220 Ohm)
#define GREEN_LED_PIN D7 // GPIO44: Green Safe LED (+220 Ohm)
Servo gateHazard, gatePcb;
Adafruit_SSD1306 display(128, 64, &Wire, -1);
int batteryCount = 0, pcbCount = 0, plasticCount = 0;
bool initCamera() {
camera_config_t cfg = {};
cfg.ledc_channel = LEDC_CHANNEL_0;
cfg.ledc_timer = LEDC_TIMER_0;
cfg.pin_d0 = Y2_GPIO_NUM; cfg.pin_d1 = Y3_GPIO_NUM;
cfg.pin_d2 = Y4_GPIO_NUM; cfg.pin_d3 = Y5_GPIO_NUM;
cfg.pin_d4 = Y6_GPIO_NUM; cfg.pin_d5 = Y7_GPIO_NUM;
cfg.pin_d6 = Y8_GPIO_NUM; cfg.pin_d7 = Y9_GPIO_NUM;
cfg.pin_xclk = XCLK_GPIO_NUM; cfg.pin_pclk = PCLK_GPIO_NUM;
cfg.pin_vsync = VSYNC_GPIO_NUM; cfg.pin_href = HREF_GPIO_NUM;
cfg.pin_sccb_sda = SIOD_GPIO_NUM; cfg.pin_sccb_scl = SIOC_GPIO_NUM;
cfg.pin_pwdn = PWDN_GPIO_NUM; cfg.pin_reset = RESET_GPIO_NUM;
cfg.xclk_freq_hz = 20000000;
cfg.pixel_format = PIXFORMAT_RGB565;
cfg.frame_size = FRAMESIZE_96X96; // Matches Edge Impulse FOMO input
cfg.fb_location = CAMERA_FB_IN_PSRAM;
cfg.fb_count = 1;
return (esp_camera_init(&cfg) == ESP_OK);
}
void updateOLED(String title, String detail) {
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.println("E-WASTE FOMO SORTER");
display.drawLine(0, 10, 128, 10, SSD1306_WHITE);
display.setTextSize(2);
display.setCursor(0, 18);
display.println(title);
display.setTextSize(1);
display.setCursor(0, 42);
display.println(detail);
display.setCursor(0, 54);
display.printf("BAT:%d PCB:%d PLS:%d", batteryCount, pcbCount, plasticCount);
display.display();
}
// Replace this hook with your Edge Impulse run_classifier() FOMO loop
String runFomoDetection(camera_fb_t *fb, float &confOut) {
// In Edge Impulse: convert fb->buf RGB565 -> signal_t, call run_classifier()
// and read result.bounding_boxes[i].label + .value (confidence).
confOut = 0.92;
return "battery"; // Demo placeholder until FOMO library is linked
}
void sortItem(String label, float conf, unsigned long infMs) {
String info = "Conf:" + String((int)(conf * 100)) + "% " + String(infMs) + "ms";
if (label == "battery") {
batteryCount++;
digitalWrite(GREEN_LED_PIN, LOW);
digitalWrite(RED_LED_PIN, HIGH);
digitalWrite(BUZZER_PIN, HIGH);
updateOLED("HAZARD!", info);
gateHazard.write(75); // Swing Gate 1 -> Fire-Safe Bin
delay(900);
gateHazard.write(0); // Return Gate 1 to home
digitalWrite(BUZZER_PIN, LOW);
digitalWrite(RED_LED_PIN, LOW);
digitalWrite(GREEN_LED_PIN, HIGH);
} else if (label == "pcb" || label == "cable") {
pcbCount++;
updateOLED("PCB/WIRE", info);
delay(350); // Wait for belt travel to Gate 2
gatePcb.write(75); // Swing Gate 2 -> PCB Recovery Bin
delay(800);
gatePcb.write(0);
} else {
plasticCount++;
updateOLED("PLASTIC", info);
delay(600); // Pass straight through to General Bin
}
// Print JSON packet (publish over Wi-Fi MQTT in full deployment)
Serial.printf("{\"class\":\"%s\",\"conf\":%.2f,\"inf_ms\":%lu,\"hazards\":%d}\n",
label.c_str(), conf, infMs, batteryCount);
}
void setup() {
Serial.begin(115200);
pinMode(IR_TRIGGER_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(RED_LED_PIN, OUTPUT);
pinMode(GREEN_LED_PIN, OUTPUT);
digitalWrite(GREEN_LED_PIN, HIGH);
// I2C OLED on D4 (SDA) & D5 (SCL)
Wire.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.setTextColor(SSD1306_WHITE);
// Attach MG90S Servos (50 Hz PWM)
gateHazard.attach(SERVO_HAZARD_PIN, 500, 2400);
gatePcb.attach(SERVO_PCB_PIN, 500, 2400);
gateHazard.write(0);
gatePcb.write(0);
if (!initCamera()) {
updateOLED("CAM ERR", "Enable OPI PSRAM");
while (1) delay(1000);
}
updateOLED("READY", "Waiting for IR...");
}
void loop() {
// FC-51 IR Sensor outputs LOW when an e-waste item enters camera zone
if (digitalRead(IR_TRIGGER_PIN) == LOW) {
unsigned long t0 = millis();
camera_fb_t *fb = esp_camera_fb_get();
if (fb) {
float conf = 0.0;
String detected = runFomoDetection(fb, conf);
esp_camera_fb_return(fb);
unsigned long infMs = millis() - t0;
if (conf >= 0.75) {
sortItem(detected, conf, infMs);
}
}
while (digitalRead(IR_TRIGGER_PIN) == LOW) delay(30); // Wait until item clears
updateOLED("READY", "Waiting for IR...");
}
delay(25);
}
7. College Viva & Evaluation Q&A (6 Questions)
Expand each question to prepare confident, engineering-backed answers for your project demo and external examiners.
D0/D1) a shared voltage reference.
≥ 0.75).