Back to Expert Projects

👁️ AI Object Sorting Conveyor

Bring machine learning to hardware using an ESP32-CAM and computer vision.

📋 Overview

Train a neural network to recognize different objects (e.g. screws vs. nuts, or red vs. blue candies) and deploy the model directly to the ESP32-CAM. The camera identifies the object and a servo sorts it.

What you'll learn: Edge AI (TinyML), TensorFlow Lite for Microcontrollers, and basic computer vision pipelines.

Estimated time: 8-10 hours. Difficulty: ⭐⭐⭐⭐⭐ Expert.

🧩 Components Needed

ComponentSpecificationQtyNotes
ESP32-CAMWith OV26401
FTDI ProgrammerUSB to Serial1For uploading to ESP32-CAM
Servo MotorSG901Sorting arm
Conveyor BeltDC Motor driven1Or a simple slide

📖 Step-by-Step Tutorial

1

Data Collection

Use the ESP32-CAM to take hundreds of photos of the objects you want to sort under consistent lighting.
2

Train the Model

Use Edge Impulse (web platform) to train a lightweight image classification model on your dataset.
3

Export Arduino Library

Export the trained model as a C++ Arduino library and include it in your sketch.
4

Inference Loop

The ESP32 captures a frame, runs it through the neural network, gets a confidence score, and actuates the servo.
💡
Lighting is everything in computer vision. Build an enclosure with white LEDs around the camera to ensure the AI always sees the same shadows and colors.

💻 Code / Configuration

ai_sorter.ino
INO
// AI Sorter Inference (Snippet)
#include <esp_camera.h>
#include <edge-impulse-sdk/classifier/ei_run_classifier.h>

void loop() {
  camera_fb_t * fb = esp_camera_fb_get();
  if (!fb) return;

  // Convert frame buffer to RGB/Grayscale for Edge Impulse
  signal_t signal;
  signal.total_length = EI_CLASSIFIER_INPUT_WIDTH * EI_CLASSIFIER_INPUT_HEIGHT;
  signal.get_data = &raw_feature_get_data;

  ei_impulse_result_t result = {0};
  EI_IMPULSE_ERROR res = run_classifier(&signal, &result, false);

  if (res == EI_IMPULSE_OK) {
    for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
      if (result.classification[ix].value > 0.8) {
         Serial.println(result.classification[ix].label);
         // Move sorting servo based on label
      }
    }
  }
  esp_camera_fb_return(fb);

Reviews & Ratings

0 reviews
5★
0
4★
0
3★
0
2★
0
1★
0
...

Loading reviews...

volt-X / AI Object Sorting Conveyor — Expert Robotics Tutorial