Introduction: Soil Moisture Sensor (vSTEM)

Getting into gardening? Interested in agriculture? Just want to build a fun Arduino-based project? A 'yes' to any one of those questions means this Instructable is for you!

This soil moisture sensor is relatively easy to build, costs very little, and is surprisingly useful. Knowing the condition your soil is in can help to determine whether or not your plants have sufficient moisture. In larger scales, farmers may use similar sensors to help manage their irrigation systems more efficiently. Still curious? Check out this article to find out more.

How does it work? When you place the sensor into the soil, it'll act as a sort of resistor. If there's more water between the sensor's probes, the resistance will be lower (as the conductivity increases). If there's less water between the probes, the resistance will be higher (as the conductivity decreases). The results will then be displayed on your Arduino's Serial Monitor and visualized with the 4 LED's

This project was made in association with vSTEM and STAC Programming. Head on over to their Instructables page for more projects just like this.

This project was inspired by innovativetom's "Arduino Soil Moisture Sensor". Check out his account as well.

Supplies

Materials-wise, we'll be needing:

  • 1 Breadboard
  • 4 LEDs (Blue, Green, Yellow and Red)
  • 5 1k resistors
  • 1 Soil Moisture Sensor Kit
  • 1 Arduino Nano
  • An assortment of Jumper Wires

    Let's get started!

Step 1: Placing the Arduino and Setting Up the Breadboard

Building the circuit is fairly straight forward, especially with the diagram above.

Begin by laying the breadboard such that it is facing yourself and locate the + and - charges. Red is positive and Blue is Negative. Place the Arduino Nano in the center, with 2 prongs on one side and 3 on the other. Make sure to align the prongs such that they are placed at the end of the breadboard.

Once you get the Arduino onto the breadboard, you can start placing the wires, LED's and resistors into their respective positions. The diagram at the top illustrates the positioning of all the wires that are involved. Ensure that you connect the sensor to the Nano's A0 pin as depicted in the diagram. This will be the base of all communication between the chip and the sensor. Once given information regarding the soil's water potential, the Arduino will send current to the LED's such that they best represent the state of your soil. The LED's need to be positioned such that the blue LED is at pin 5, the green at pin 4, the yellow at pin 3 and the red at pin 2.

Once you feel everything is set up, move onto the next step.

Step 2: Helpful Tips Regarding the Breadboard

  1. Start with the Arduino Nano, as this will help give a basis for all the other wires and the sensor.
  2. When placing the lights, make sure that the shorter prong of the cathode and the resistor are aligned so that the current can flow, and you will prevent a short circuit.
  3. When more wires are placed, they become more jumbled. Take heed of this and keep track of which wires you have placed and which you haven't.
  4. Follow the diagram, and you will be successful!

Step 3: The Program

Here's the program:

int led1 = 2;int led2 = 3;int led3 = 4;int led4 = 5;int mostureSensor = 0;void setup() {  Serial.begin(9600);  Serial.println("Hello");  pinMode(led1, OUTPUT);  pinMode(led2, OUTPUT);  pinMode(led3, OUTPUT);  pinMode(led4, OUTPUT);    pinMode(moistureSensor, INPUT);}void loop() {  int sensorValue = analogRead(moistureSensor);    Serial.print ("Sensor Value: ");  Serial.print(sensorValue);      if (sensorValue >= 750)  {   digitalWrite(led1, LOW);   digitalWrite(led2, LOW);   digitalWrite(led3, LOW);   digitalWrite(led4, HIGH);  }  else if (sensorValue >= 615  && sensorValue < 750)  {   digitalWrite(led1, HIGH);   digitalWrite(led2, LOW);   digitalWrite(led3, LOW);   digitalWrite(led4, LOW);  }  else if (sensorValue >= 410 && sensorValue < 615)  {   digitalWrite(led1, LOW);   digitalWrite(led2, HIGH);   digitalWrite(led3, LOW);   digitalWrite(led4, LOW);  }  else if (sensorValue >= 0 && sensorValue < 410)  {   digitalWrite(led1, LOW);   digitalWrite(led2, LOW);   digitalWrite(led3, HIGH);   digitalWrite(led4, LOW);  }}

Simply Copy & Paste it into your Arduino's IDE and then compile & upload it to your Nano.

This program sets up the 4 LED's as outputs and the moisture sensor as an input. The sensor's value is then read and based on its value, a certain LED will be lit up. We'll make more sense of the if statements and what the LED's mean in the following steps.

Step 4: Operation Manual

As you'll notice in the IDE's Serial Monitor, this sensor returns a positive value. This value is known as the analogous water potential and is essentially an estimate regarding how much water can still be added to the soil. 750 is generally considered to be a maximum, and anything above that is considered over-watering. Here's a quick operation rundown - letting you know what the LED's signify and what that means for your soil.

Blue: >= 750 - A value in the sensor above 750 indicates the highest water potential. There is too much water in your soil and you may need to cut down on watering.

Green: >= 615 and < 750 - A value between 615 and 750 indicates a water potential that is average for most plants. This signifies good watering and soil moisture.

Yellow: >= 410 and < 615 - A value between 410 and 615 indicates a slightly lower water potential. You may need to water your plants a little more if you feel as though there are tell-tale signs of dehydration.

Red: >= 0 and < 410 - A value between 0 and 410 shows that the soil is too dry. As a result, the plants cannot receive the proper nutrients and are at the risk of dying.

Step 5: You're Done!

Not sure whether you've done it right? Check out the video above for reference. (Video Coming Soon).

You're soil sensor is now ready to be used! Experiment with it in your garden and let us know what you find out!

Again, this project was done in association with both vSTEM and STAC Programming. Check out their page for more content just like this.