Jump to main content

Monitor Plant Health with a Color Sensor

1
2
3
4
5
41 reviews

Abstract

Do you have a garden or houseplants? What about living on or a near a farm? How often do you check your plants' leaves for discoloration? What if you could build a robot to check for you, and warn you if your plants are getting sick? In this project you will learn to use a color sensor to identify different colors on leaves, which can give you a warning about problems like pests, diseases, or nutrient deficiency. Get ready to automate your gardening!

Summary

Areas of Science
Difficulty
Method
Time Required
Average (6-10 days)
Prerequisites

Previous experience with Arduino is recommended before you try this project. See our How to Use an Arduino page.

Material Availability

A kit is available from our partner Home Science Tools®. See the Materials section for details.

Cost
Average ($50 - $100)
Safety

No issues

Credits
Science Buddies is committed to creating content authored by scientists and educators. Learn more about our process and how we use AI.

Objective

Build a color sensor circuit to detect different color leaves. 

Introduction

The appearance of a plant's leaves can tell you a lot about the plant's health. Discolored leaves can be a sign of an underlying issue like nutrient deficiency, over/under-watering, too much (or too little) exposure to sunlight, pests, or fungus. The type of discoloration can vary depending on the plant and underlying problem. Discoloration can come in multiple forms, including changes in color, location, size, and shape of spots. For example, there can be a single, large spot (Figure 1) or numerous small spots (Figure 2). Monitoring the leaves for any issues can help you identify the cause of the problem and, if necessary, isolate it from other plants or treat it before there is further damage to the plant.

Figure 1. Bacterial infection (Xanthomonas campestris) on a Chinese cabbage leaf.

Figure 2. Symptoms of black rot (Guignardia bidwellii) on grape leaf 

If you have a small garden or a couple of house plants, taking a quick glance at the leaves every day might not be a big problem. But what if you have a huge backyard garden or even a farm? You might not have time to walk around and look at every single plant every day. What if you could build a robot to monitor your plants' health for you? In this project you will use a color sensor to detect different color leaves. The color sensor responds to different wavelengths of visible light. Just like our eyes, it specifically responds to red, green, and blue light, which can be mixed to form other colors like yellow and brown. As explained in the following video, you will need to calibrate the sensor to identify the leaves. 

In this project, you will need to pick plants to work with. You can then calibrate the sensor to identify healthy green leaves and discolored leaves and alert the user (you!) using something like an LED or buzzer when an unhealthy leaf is detected. You can look up what the specific type of discoloration means for your plants and how to treat it (some references in the Bibliography can help with this). Optionally, you can mount your color sensor on a robotic arm or a mobile robot (see the Variations section).

Terms and Concepts

Questions

Bibliography

Materials and Equipment Buy Kit

Recommended Project Supplies

Get the right supplies — selected and tested to work with this project.

View Kit

Disclaimer: Science Buddies participates in affiliate programs with Home Science Tools®, Amazon.com, Carolina Biological, and Jameco Electronics. Proceeds from the affiliate programs help support Science Buddies, a 501(c)(3) public charity, and keep our resources free for everyone. Our top priority is student learning. If you have any comments (positive or negative) related to purchases you've made for science projects from recommendations on our site, please let us know. Write to us at [email protected].

Experimental Procedure

This project follows the Engineering Design Process. Confirm with your teacher if this is acceptable for your project, and review the steps before you begin.
Before you begin: Review How to Use an Arduino Tutorials 1-3.

Build Your Circuit

Assemble your circuit as shown in Figures 3 and 4. Important: depending on where you bought your breadboard, the left-right orientation of the power and ground buses may be reversed. 

  1. Connect red, yellow, and green LEDs to Arduino pins 8, 9, and 10 respectively. Use 220Ω current-limiting resistors for the Arduino UNO R3 and 470Ω resistors for the UNO R4. 
  2. Connect the color sensor pins as follows. Use male-female jumper wires to connect the color sensor pins to your breadboard. Important: depending on where you bought your sensor, the physical order of the pins on your sensor board might not match Figures 3 and 4. Make sure you read the labels on your sensor and connect the pins accordingly.
    1. VCC pin to 5V (your sensor may have more than one VCC pin).
    2. GND pin to GND (your sensor may have more than one GND pin).
    3. S0 to Arduino pin 2
    4. S1 to Arduino pin 3
    5. S2 to Arduino pin 4
    6. S3 to Arduino pin 5
    7. LED to 5V
    8. OUT to Arduino pin 6
Figure 3. Breadboard diagram for connecting the color sensor and LEDs. Note that the pins on your color sensor may be in a different order, and the left/right orientation of the power (+) and ground (-) buses on your breadboard may be reversed.
Figure 4. Pinout diagram for the TCS3200 color sensor. Remember that the pins on your sensor may be in a different order, so make sure you read the pin labels. 

Test the Code

  1. Download color_sensor_LEDs.ino.
  2. Read through the commented code so you understand how it works.
  3. Upload the code to your Arduino.
  4. Open the serial monitor (Tools→Serial monitor).
  5. Look at the red, green, and blue (RGB) values printed out on the serial monitor.
  6. If you have not already, make sure you watch the tutorial video about the color sensor in the introduction. Remember that a smaller number (the pulse width measured by the pulseIn function) means more of that color light. If you find this confusing, you can uncomment the lines of code that use the Arduino map function. You can use this function to convert the light readings to a range where a bigger number means more light. 
  7. Experiment with holding the color sensor over different color surfaces and at different distances and watch how the RGB values change. 

Calibrate Your Sensor

  1. Gather the leaves that you plan to use for your experiment. Make sure you have several samples each of at least two different colors (healthy and unhealthy). 
  2. Using the resources in the Bibliography, or other resources that you find online, try to figure out what the discoloration means for your specific plant species. What are some possible underlying causes? How are they treated?
  3. Make a data table like Table 1. Add rows as needed.
  4. For each leaf, fill in the actual color that you see with your eyes in the data table (green, yellow, brown, etc.).
  5. Hold the color sensor directly over the leaf at a constant distance, and watch the RGB values in the serial monitor. They will fluctuate slightly even if you hold the sensor perfectly still. Write down typical or average values for the red, green, and blue readings. 
  6. Repeat this process for each one of your leaves. If your leaves are large enough, you can even take readings at different locations on each leaf. 
Swipe left to see more
Swipe left to see more
Leaf number Actual Color Red Value Green Value Blue Value
1
2
3
...

Table 1. Example data table.

  1. Based on the values you recorded in Table 1, now you will need to add conditions to the if statements in the code to detect certain colors. For example, the condition (red > 40 && green < 20 && blue > 30) will be true if the red value is greater than 40, the green value is less than 20, and the blue value is greater than 30. This means that there is more green light and less red or blue light (assuming you are not using the map function to change the values so that a bigger number means more light, in which case you would need to reverse the greater than and less than signs). You can read more about if statements, logical operators, and comparison operators in the Structure section of the Arduino language reference.
  2. Enter conditions you developed in the previous step in the code where it says "FILL IN YOUR CONDITIONS HERE" and uncomment the if/else statements. Re-upload the code to your Arduino and try holding the sensor over different leaves. Do the red, yellow, or green LEDs light up appropriately? If not, watch the RGB values in the serial monitor. How do they compare to the values you entered in your if statement conditions? You may need to leave a slight buffer or margin for error in your values. For example, if you typically read a green value of 20 on a green leaf, you could set the condition for green<25.
  3. Continue iteratively testing your leaves and adjusting the conditions for your if statements. Document your conditions for each iteration in your lab notebook. Can you adjust your code so you avoid false positives (detecting a healthy leaf as unhealthy) or false negatives (detecting an unhealthy leaf as healthy)?
  4. What other changes or improvements could you make to your code? See the Variations section for more ideas. 
  5. Going forward, how could you use your color sensor to monitor plant health? What would your treatment plan be when you detect unhealthy leaves?
icon scientific method

Ask an Expert

Do you have specific questions about your science project? Our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Global Goals

The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.

This project explores topics key to Zero Hunger: End hunger, achieve food security and improved nutrition and promote sustainable agriculture.

Variations

  • Can you mount a color sensor on a mobile robot? What about a robotic arm? You could even combine the two, and put a robotic arm on a mobile robot! This would allow your robot to drive around and check different plants. 
  • Can you use a buzzer as an alarm when you detect a discolored leaf?

Careers

If you like this project, you might enjoy exploring these related careers:

Career Profile
Just as a potter forms clay, or a steel worker molds molten steel, electrical and electronics engineers gather and shape electricity and use it to make products that transmit power or transmit information. Electrical and electronics engineers may specialize in one of the millions of products that make or use electricity, like cell phones, electric motors, microwaves, medical instruments, airline navigation system, or handheld games. Read more
Career Profile
With a growing world population, making sure that there is enough food for everyone is critical. Plant scientists work to ensure that agricultural practices result in an abundance of nutritious food in a sustainable and environmentally friendly manner. Read more
Home Science Tools®

Contact Us

Our kits are developed in partnership with Home Science Tools®. If you have purchased a kit for this project, Home Science Tools® is pleased to answer any questions.

In your email, please follow these instructions:
  1. Include your Home Science Tools® order number.
  2. Please describe how you need help as thoroughly as possible:

    Examples

    Good Question I'm trying to do Experimental Procedure step #5, "Scrape the insulation from the wire. . ." How do I know when I've scraped enough?
    Good Question I'm at Experimental Procedure step #7, "Move the magnet back and forth . . ." and the LED is not lighting up.
    Bad Question I don't understand the instructions. Help!
    Good Question I am purchasing my materials. Can I substitute a 1N34 diode for the 1N25 diode called for in the material list?
    Bad Question Can I use a different part?

Contact Support

News Feed on This Topic

 
, ,

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Finio, Ben. "Monitor Plant Health with a Color Sensor." Science Buddies, 5 Nov. 2025, https://www.sciencebuddies.org/science-fair-projects/project-ideas/Elec_p110/electricity-electronics/leaf-color-detection?from=Blog. Accessed 10 June 2026.

APA Style

Finio, B. (2025, November 5). Monitor Plant Health with a Color Sensor. Retrieved from https://www.sciencebuddies.org/science-fair-projects/project-ideas/Elec_p110/electricity-electronics/leaf-color-detection?from=Blog


Last edit date: 2025-11-05
Top
Free science fair projects.