Homautomation.org

or How do I automate my home

Menu
  • An online resistor calculator
  • Fritzing Parts
Menu

Measure soil Moisture with Arduino – Gardening

Posted on 06/20/201406/18/2019 by Vincent Demay

Needed Hardware

ArduinoUno_r2_front450px

Arduino Uno

Price: less than $30 (Amazon)

A moisture sensor
Price: less than $7 (Amazon)

Simple Way to connect to the Arduino

arduino-uno

code

int sensorPin = 0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
 
void setup() {
  // declare the ledPin as an OUTPUT:
   Serial.begin(9600);  
}
 
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
  delay(1000);          
  Serial.print("sensor = " );                       
  Serial.println(sensorValue);                   
}

Output

Sensot in air: value = 0

sensor = 0
sensor = 0
sensor = 0
sensor = 0

Sensor in dry soil:  0 < value  < 300

sensor = 35
sensor = 41
sensor = 38
sensor = 49

Sensor in humid soil: 300 < value < 700

sensor = 578
sensor = 576
sensor = 582
sensor = 589

Sensor in water: value > 700

sensor = 934
sensor = 940
sensor = 938
sensor = 940

Drawbacks

Using this sensor on this way always makes current cross over the sensor. It can cause corrosion across the probes.

photo

Solutions:

  • Do not left in place the sensor.
  • Stop to power the sensor when is not used (see below)

Keep your sensor alive for a while

Here the aim is to stop to power the sensor when it is not used. Let says we want to get a value each 1min.

PNP_2

Code

int sensorPin = 0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
 
int sensorVCC = 13;
 
void setup() {
  // declare the ledPin as an OUTPUT:
   Serial.begin(9600);  
   pinMode(sensorVCC, OUTPUT); 
   digitalWrite(sensorVCC, LOW);
}
 
void loop() {
  // power the sensor
  digitalWrite(sensorVCC, HIGH);
  delay(100); //make sure the sensor is powered
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin); 
  //stop power 
  digitalWrite(sensorVCC, LOW);  
  //wait
  delay(60*1000);          
  Serial.print("sensor = " );                       
  Serial.println(sensorValue);                   
}

 Perspectives

This kind of sensor can be used to check plant watering or to auto water a plant.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How to use hall sensor TLE 4913 with arduino
  • Four amazing projects based on WS2801 led strip
  • Pilot wire for electrical heaters
  • DS18B20 : How to change resolution (9/10/11/12 bits)?
  • Arduino, How to know the state of an output pin?

Recent Comments

  • Jan Hendrickx on Expand Arduino IO with 1wire DS2408
  • Jan Hendrickx on Expand Arduino IO with 1wire DS2408
  • Jan Hendrickx on Expand Arduino IO with 1wire DS2408
  • Jan Hendrickx on Expand Arduino IO with 1wire DS2408
  • Vincent Demay on Expand Arduino IO with 1wire DS2408

Archives

  • June 2019
  • December 2015
  • November 2015
  • September 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • June 2014
  • April 2014
  • March 2014
  • February 2014
  • October 2013
  • September 2013

Categories

  • Arduino
  • Electronics
  • Non classé

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
©2019 Homautomation.org | Built using WordPress and Responsive Blogily theme by Superb