Home Sensor Projects Soil moisture sensor example

Soil moisture sensor example

by shedboy71

This Moisture Sensor uses Immersion Gold which protects the nickel from oxidation. Electroless nickel immersion gold (ENIG) has several advantages over more conventional (and cheaper) surface platings such as HASL (solder), including excellent surface planarity (particularly helpful for PCB’s with large BGA packages), good oxidation resistance, and usability for untreated contact surfaces such as membrane switches and contact points.

They can be very to use, just insert it into the soil and then read it. With help of this sensor, it will be realizable to make the plant remind you : Hey, I am thirsty now, please give me some water. This Moisture Sensor uses the two probes to pass current through the soil, and then it reads that resistance to get the moisture level. More water makes the soil conduct electricity more easily (less resistance), while dry soil conducts electricity poorly (more resistance).

This item have low power consumption, and high sensitivity, which are the biggest characteristics of this mdoule. This item can be used with Arduino UNO,Arduino mega2560,Arduino ADK etc.

 

Layout

This example also has 2 LEDs to indicate whether you need to water the plant or not – easier than looking at the serial monitor output

 

 

Code

[codesyntax lang=”cpp”]

int waterPin = A0;
int greenLED = 5;
int redLED = 4;

int threshold = 750; //adjust depending on the value you wish to check for

void setup()
{
  //set pins and enable serial
  pinMode(waterPin, INPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  digitalWrite(greenLED, LOW);
  digitalWrite(redLED, LOW);
  Serial.begin(9600);
}

void loop() {
  // read the input on analog pin 0:
  int moistureValue = analogRead(waterPin);
  Serial.print(moistureValue);
  if(moistureValue < threshold)
  {
    Serial.println(" : No water required");
    digitalWrite(redLED, LOW);
    digitalWrite(greenLED, HIGH);
  }
  else 
  {
    Serial.println(" : I'm thirsty");
    digitalWrite(redLED, HIGH);
    digitalWrite(greenLED, LOW);
  }
  delay(1000); //adjust if the readings are too slow/fast
}

[/codesyntax]

 

Links
Soil Moisture Sensor Hygrometer Module for Arduino 2560 UNO 1280 Free Shipping

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More