• Register
  • Login
  • this message might be for you!

    This is a simple arduino project for a soil moisture sensor that will light up a LED at a certain moisture level. It uses Arduino Duemilanove microcontroller board. Two wires placed in the soil pot form a variable resistor, whose resistance varies depending on soil moisture. This variable resistor is connected in a voltage divider configuration, and Arduino collects a voltage proportional to resistance between the 2 wires.

    Insert the 2 probes (wires, pcb) in the dry soil and measure the resistance value and then pour water and measure it again.
    Use a mid value for the resistor (eg: 50kΩ for 100kΩ in dry soil and 10kΩ in wet).

    The other method to find the resistor’s value is to try different values or use a potentiometer. Insert the probes into the soil that has the desired moisture when to light up the LED and signal that the plant needs water.

    Adjust the potentiometer and see the point at which it starts to light. Measure the potentiomenter current value and replace it with a fixed resistor.

    Arduino soil moisture sensor schematic

    arduino project soil moisture sensor schematic

    Project source code

    const int VAL_PROBE = 0; // Analog pin 0
    const int MOISTURE_LEVEL = 250; // the value after the LED goes ON
     
    void setup() {
        Serial.begin(9600);
    }
     
    void LedState(int state) {
        digitalWrite(13, state);
    }
     
    void loop() {
        int moisture = analogRead(VAL_PROBE);
     
        Serial.println(moisture);
     
        if(moisture > MOISTURE_LEVEL) {
            LedState(HIGH);
        } else   {
            LedState(LOW);
        }
        delay(100);
    }

    Source (romanian): http://www.tehnorama.ro/cum-sa-faci-o-floare-sa-te-traga-de-maneca-atunci-cand-ai-uitat-sa-o-uzi/


    ask a question
    

    15 Responses to "Simple Soil Moisture Sensor – Arduino Project"

    1. This Circuit can´t work, because the Ground Pin is directly attached to AnalogPin 0. That mean that the analogRead(VAL_PROBE) always returns a 0. The Resistor should be placed in the line between Gnd and Analog Pin 0. Otherwise there is no Voltage Divider.

    2. Half-Baked Circuit !

      1.Analogue input pin (0)is directly connected to 0V.

      2.Arduino has a built in LED at pin 13.Then why you prefer an external LED?

      • sorry just seeing this and apologizes ahead of time.

        Half baked?

        1. How about a positive response like the person above you or did you just want to run your mouth.

        2. build in LED may not be bright enough or point in the correct orientation. Like you.

    3. A similar working circuit places the resistor before the ground…. Before I rambled on, I realized the first comment already covers what is wrong with your circuit design.

    4. No need to add anything here, it all has been said.
      If you end up here, looking for a way to measure soil humidity: look here:
      http://www.instructables.com/id/Watering-your-plants-with-a-microcontroller/
      or:
      http://www.instructables.com/id/Irrigating-your-garden-with-an-opamp-The-circuit/

    5. WORKS LIKE A CHARM!!
      Thanks a lot!

    6. Hello sir… just want to know how to get the analog value of the sensor.. I mean in the sketch you put const int MOISTURE_LEVEL = 250.. where to measure that part.. plz help me.. im little lost rite now..

    7. why we connect resistance in this practicle?

    8. I need assistance in how to simulate it on proteus 7.9

    9. How do I represent it on proteus 7.9.pls I need urgent response

    10. how to connect arduino to sensor? i need clear diagram

    11. any one can be explain the function of resistence and why it is used her?

    12. the resistor is used as a voltage divider

    13. It works well thanks for the editor, I have made some amendment to change the equipment to flood sensor, it activates a 12V relay via a transistor, R=10kohms, this is the sketch:

      const int VAL_PROBE = 0; // Analog pin 0
      const int MOISTURE_LEVEL = 900; /* the value after the LED goes ON */

      void setup() {
      Serial.begin(9600);
      }

      void LedState(int state) {
      digitalWrite(12, state);
      }

      void loop() {
      int moisture = analogRead(VAL_PROBE);

      Serial.println(moisture);

      if(moisture > MOISTURE_LEVEL) {
      LedState(LOW);
      } else {
      LedState(HIGH);
      }
      delay(400);
      }

    You need to log in if you need to post comments on ElectroSchematics.com or register if you do not have an account.