ESP32 and ML grade tomatoes by size and color uniformity on the line

A maker known as Pmalfa31 has built a tomato grading system around an ESP32 microcontroller using machine learning. The device assesses fruit quality on a conveyor and checks color consistency within a batch—minor differences between packages are acceptable, but too much variation inside one box counts as a defect.
The setup knows in advance whether standard tomatoes or cherry tomatoes are being processed and switches between two separate trained models accordingly. Raw data arrives from an optical sensor, then the software discards frames of an empty belt, calculates statistical metrics, and combines readings that belong to a single fruit.
A notable feature is the heuristic validation layer. Since the approximate size of a tomato is known, the code flags fruits that look too large for a cherry or too small for a standard variety. This reduces misclassifications, though it does not eliminate them entirely.
The program is memory-hungry, so it demands a much larger stack than usual. For those who want to try it, the author posted a web-based simulator, so no hardware or actual tomatoes are needed. The code is also available for modification and study.
This project is just one example of how computing is finding its way into modern farming, gradually replacing manual work in tasks ranging from sorting to field monitoring.


