moisture sensor with arduino

MOISTURE SENSOR: -Soil moisture sensors measure the volumetric water content in soil. By using some other property of the soil, such as electrical resistance, dielectric constant and conductivity we are usable to make such a arduino project which can be really help full in many areas. like Rain sensor , Auto gardening and etc. 



Component to be needed: - Arduino moisture sensor can be made with some easy stuff which could be available easily.
1. Arduino board: - AN arduino board is a pre-fabricate training board which is now being manufactured by many companies and it is really very cheap. you can get all detail about the arduino board from the link below https://www.arduino.cc/ . and you can bye an arduino board from 

https://www.amazon.in/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=arduuino+board&rh=i%3Aaps%2Ck%3Aarduuino+board


2.Moisture sensor: - A soil moisture sensor is a basically a two conducting wire which is used to measure the conductivity between two point in ground or garden.
Soil moisture sensors measure the volumetric water content indirectly by using some other property of the soil, such as electrical resistance, 

so you can use two normal wire with Op-Amp or bye a soil moisture sensor from https://www.amazon.in/s/ref=nb_sb_ss_c_0_15?url=search-alias%3Daps&field-keywords=soil+moisture+sensor&sprefix=soil+%2Cmoisture+%2Caps%2C253 .
3. Battery: - You can use a 12V DC battery which can be obtain from online or off line from any electronics store.
4.Led: -  you will need cople of leds i you project to indicate or  to know the out put. and some 1K register with it.




Fig: - Component details.





Code for ARDUINO: -Add 1K resistors to the LEDs and correct the code so that the red LED will light.
The probe only needs to be on while a reading is taken, so poll the probe for one second every half hour by driving it from a digital pin. In my example code I used D7. This greatly improves power consumption and extends the life of the probe by several orders of magnitude since damage by electrolysis will be insignificant. If you want to check after watering, just press reset for a new reading.


A0 - Soil Mosture Sensor
D2:D6 - LEDS 1,2,3,4,5
LED1 - Green
LED2 - Green
LED3 - Green
LED4 - YELLOW
LED5 - RED
Connect the Soil Mosture Sensor to anolog input pin A0,
and your 5 led to digital out 2-6
*/
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int probe = 7;
int mostureSensor = 0;
void setup() {
// Serial Begin so we can see the data from the mosture sensor in our serial input window.
Serial.begin(9600);
// setting the led pins to outputs
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(probe, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// Power-up the probe and pause for the driver
digitalWrite(probe, HIGH);
delay(1000);
// read the input on analog pin 0:
int sensorValue = analogRead(mostureSensor);
// print out the value you read:
Serial.println(sensorValue);
if (sensorValue >= 820)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
}
else if (sensorValue >= 615 && sensorValue < 820)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led5, LOW);
}
else if (sensorValue >= 410 && sensorValue < 615)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
}
else if (sensorValue >= 250 && sensorValue < 410)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
}
else if (sensorValue >= 0 && sensorValue < 250)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
}
// Power-down the probe
digitalWrite(probe, LOW);
delay(1800000); // wait half an hour
}

And keep remember that moisture sensor which you have bought will give value high when conductivity is zero(soil without moisture) between two polls and it will give value low when conductivity is high(soil with moisture). Because the output of sensor is inverted.


Comments