Vegetables and Fruits Ripeness Detection by Color

Collate spectral color data of varying fruits and vegetables and interpret this data set with a neural network to predict ripening stages.

Similar projects worth following
Thanks to our evolved acuity, it is not struggling for us to detect ripeness by the appearance of a fruit or vegetable. However, nowadays, foods are a subject of mass production. Thus, we need a more reliable and effortless method to distinguish fruits and vegetables depending on their ripeness than the naked eye. In the hope of assisting food companies, grocery stores, and farmers in sorting fruits and vegetables, I developed this device that detects ripening stages by spectral color with a neural network model.

As fruits and vegetables ripen, they change color because of the four families of pigments:

  • chlorophyll (green)
  • carotenoids (yellow, red, orange)
  • flavonoids: anthocyanins + anthoxanthins (red, blue, purple)
  • betalains (red, yellow, purple)

These pigments are groups of molecular structures absorbing a specific set of wavelengths and reflecting the remainder. Unripe fruits are green because of chlorophyll in their cells. As they ripen, the chlorophyll breaks down and is replaced by orange carotenoids and red anthocyanins. These compounds are antioxidants that prevent the fruit from spoiling too quickly in the air. Then, the enzymatic browning occurs and causes discoloration - turning brown. Enzymes function as a catalyst for chemical reactions instigating discoloration, such as:

  • hydroxylation of phenols
  • oxidation of phenols

After doing some research on color-changing processes as fruits and vegetables ripen, I decided to build an artificial neural network (ANN) based on the classification model to interpret the spectral color of varying fruits and vegetables to predict ripening stages.

Before building and testing my neural network model, I developed a web application in PHP to collate the spectral color data of fruits and vegetables generated by the AS7341 visible light sensor to create a ripening stages data set by spectral color. I used an Arduino Nano 33 IoT to send the data produced by the visible light sensor to the web application. Empirically, I assigned a ripening stage (label) while obtaining spectral color data for each fruit and vegetable by using four class buttons connected to the Nano 33 IoT:

  • Early Ripe
  • Partially Ripe
  • Ripe
  • Decay

After completing the data set, I built my artificial neural network (ANN) with TensorFlow to make predictions on the ripening stages (labels) based on spectral color.

Then, after testing, I conducted experiments with my neural network model to predict the ripening stages of varying fruits and vegetables by spectral color. As far as my experiments go, the model is working impeccably.

So, this is my project in a nutshell 😃

In the following steps, you can find more detailed information on coding, data collection, and building an artificial neural network model with TensorFlow.

Huge thanks to DFRobot for sponsoring this project.

Sponsored products by DFRobot:

⭐ DFRobot AS7341 11-Channel Visible Light Sensor | Inspect

Step 1: Developing a web application in PHP to collate spectral color data of fruits and vegetables

I developed this web application (Vegetables and Fruits Data Logger) in PHP to obtain spectral color data of fruits and vegetables from the AS7341 visible light sensor via the Arduino Nano 33 IoT and insert this data into a CSV file (spectral_color_database.csv) to create a ripening stages data set by spectral color.

The web application includes one file (index.php) and requires these parameters to insert a new row (entry) to the data set:

  • F1
  • F2
  • F3
  • F4
  • F5
  • F6
  • F7
  • F8
  • nir_1
  • nir_2
  • class

💻 index.php

⭐ Check whether all required parameters are transferred by the Nano 33 IoT.

⭐ If so, create the data array with the obtained parameters, including the current date.

⭐ Insert the recently generated data array into the spectral_color_database.csv file as a new row by using the fputcsv function.

⭐ Then, print: Data Inserted Successfully!

⭐ If there are omissions or no incoming data, print: Waiting for data from the AS7341 sensor to insert...

# Check the incoming data packet:if(isset($_GET["F1"]) && isset($_GET["F2"]) && isset($_GET["F3"]) && isset($_GET["F4"]) && isset($_GET["F5"]) && isset($_GET["F6"]) && isset($_GET["F7"]) && isset($_GET["F8"]) && isset($_GET["nir_1"]) && isset($_GET["nir_2"]) && isset($_GET["class"])){	# Create the data array.	$data = array($_GET["F1"], $_GET["F2"], $_GET["F3"], $_GET["F4"], $_GET["F5"], $_GET["F6"], $_GET["F7"],...
Read more »

  • 1 × Arduino Nano 33 IoT
  • 1 × DFRobot AS7341 11-Channel Visible Light Sensor
  • 1 × Raspberry Pi 3B+ or 4
  • 1 × 10K Potentiometer (Long-Shaft)
  • 1 × Potentiometer Knob

View all 9 components

  • 1

View all instructions

Enjoy this project?



Faith wrote 11/29/2021 at 16:40 point

Hi! I have a question about the circuit connections and the way you color-coded them. Are there specific functions for the different colored wires?

  Are you sure? yes | no

kutluhan_aktar wrote 07/06/2021 at 18:54 point

Please feel free to leave a comment here if you have any questions or concerns regarding this project 😃

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates