RoboBin is an automated waste classification and sorting system built using two ESP32-based microcontrollers:
- Node32s (ESP32 Board) – Handles sensing (ultrasonic), actuation (servo), display (I2C LCD), and WebSocket communication with the FastAPI server.
- ESP32-CAM – Captures waste images upon trigger, sends them to the FastAPI server for classification, and receives acknowledgment.
Both devices communicate with the FastAPI backend using WebSockets for real-time synchronization.
| Component | Role | Communication | Notes |
|---|---|---|---|
| Node32s (ESP32) | Detects object via ultrasonic sensor, controls servo, updates LCD, communicates with server | WebSocket /ws/sensor |
Triggers image capture, receives classification |
| ESP32-CAM | Captures waste image and sends it to the FastAPI server | WebSocket /ws/image |
Receives capture signal from Node32s via server |
| FastAPI Server | Central logic hub that runs ML classification and coordinates both devices | WebSocket + HTTP | Classifies images and returns results |
The Node32s serves as the main control board.
It detects nearby waste using the ultrasonic sensor, triggers classification when necessary, and drives a servo to open/close the bin based on classification.
- Ultrasonic object detection
- Sends
"object_detected"event to server - Receives classification results (
"0"or"1") - Controls servo motor accordingly
- Displays feedback via I2C LCD
- Supports OTA (Over-the-Air) firmware updates
| Pin | Component | Function |
|---|---|---|
| GPIO 4 | Ultrasonic Sensor | TRIG |
| GPIO 5 | Ultrasonic Sensor | ECHO |
| GPIO 13 | Servo Motor | PWM Signal |
| GPIO 21 | I2C LCD | SDA |
| GPIO 22 | I2C LCD | SCL |
WiFi.hWebSocketsClient.hESP32Servo.hLiquidCrystal_I2C.hArduinoOTA.h(for OTA updates)
The ESP32-CAM handles image acquisition.
When triggered by the Node32s (via the FastAPI server), it captures an image and sends it to the server for machine learning classification.
- Waits for
"capture"command from the FastAPI server. - Captures an image using the onboard camera.
- Sends binary image data to
/ws/imageendpoint. - Receives classification feedback for confirmation.
- Can also support OTA updates for remote reprogramming.
Most pins are pre-assigned internally to the OV2640 camera, but ensure:
- GPIO 0 → GND (for flashing only; remove after upload)
- GPIO 4 → LED (optional indicator)
- 5V → VIN
- GND → GND
- Detection: Node32s detects an object within 20 cm and sends
"object_detected"via WebSocket/ws/sensor. - Trigger: The FastAPI server forwards
"capture"command to the ESP32-CAM via/ws/image. - Capture: ESP32-CAM captures and uploads an image to the FastAPI server.
- Classification: Server runs the ML model and determines the class:
"0"→ Biodegradable"1"→ Non-biodegradable
- Action: Server sends classification back to Node32s.
- Servo Response: Node32s moves the servo to the appropriate bin.
- Resume: Server signals
"resume_sensing"to Node32s to restart detection.
Both ESP32 boards support OTA updates using the ArduinoOTA library.
- Connect your PC and the board to the same Wi-Fi network.
- In Arduino IDE:
- Go to Tools → Port → Network Ports
- Select the device (e.g.
RoboBin_Node32sorRoboBin_CAM)
- Click Upload — no USB needed!
ArduinoOTA.setHostname("RoboBin_Node32s");
ArduinoOTA.setPassword("yourpassword");