Introduction: Soil Moisture Sensor DIY

In my 1st and 2nd grade classroom, an activity we complete is planting pumpkin seeds. We plant the pumpkin seeds as a class in the spring, and students bring their seeds home to plant their seeds and watch the pumpkin grow. Since planting day, pumpkins have been a daily discussion in our classroom. Some students report that they have not watered their pumpkins at all; whereas others say they have standing water on top of their soil. All of these discussions made we wonder about the appropriate moisture for different types of plants. I began to do some research and was inspired to build my own Soil Moisture Sensor using my Arduino Uno. This project uses nuts and bolts to measure the percentage of moisture in the soil. The RGB LED connected to the Arduino Uno changes colors to represent different percentages of moisture. The Soil Moisture Sensor is a great project for the garden enthusiast and beginning Arduino Uno user.

Step 1: Gather Materials

  • 1-Arduino Uno
  • 1-Breadboard
  • 1-RGB LED
  • 2-Long Jumper Cables
  • 6-Short Jumper Cables
  • 1-10k resistor
  • 3-330 ohm resistors
  • 2-Bolts of any size
  • 2-Nuts to match bolts above

Step 2: Build Prongs

  1. Place the nut on the bolt.
  2. Tighten until the nut is about 1/8 inch from the head of the bolt.
  3. Place one end of the jumper wire between the nut and the head of the bolt.
  4. Continue to tighten until the jumper wire is secured between nut and bolt.
  5. Repeat steps 1-4 to create 2nd prong.

Step 3: Build Circuit

The wires labeled out represent the sensor prongs.

Step 4: Write Code

Click here for the complete code.

Step 5: Calculate

  1. Open serial monitor.
  2. Hold prongs in air and record the number displayed on the serial monitor. This will be your value for 0% moisture. (This number should be at 0)
  3. Hold prongs in a dish of water. Record the number displayed on the serial monitor. This will be your value for 100% moisture.
  4. Solve for x. 100=(high value) (x)
  5. My high value was 650 so the equation was 100=650x and was solved as follows: x=100/650 to get the x value of 0.15384615.

Step 6: Revise Code

  1. Add value calculated in the previous step into the code.
  2. View lines 18 and 19 to see the added code.
  3. Here is the final code.

The RGB LED will change color based on the moisture percentage recorded in the serial monitor. The colors are as follows:

  • 0%-20%=Red--Serial Reading of less than 130
  • 21%-40%=Yellow--Serial reading between 131 and 260
  • 41%-60%=Green--Serial reading between 261 and 390
  • 61%-80%=Blue--Serial reading between 391 and 520
  • 81%-100%=Purple--Serial reading between 521 and 650

The colors were set to match those found on this chart.

Step 7: Test

Place prongs into the soil approximately 1 inch apart. View the serial monitor and light to see the plant's soil moisture. Use the following guide to see if your plant is at the correct moisture.

Step 8: Sources of Inspirations

Instructables. (2019, January 26). DIY Plant Moisture Sensor W/ Arduino. Retrieved May 17, 2019, from

Instructables. (2019, May 09). DIY SOIL MOISTURE SENSOR CHEAP YET ACCURATE ! Retrieved May 19, 2019, from