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 »
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?