Moisture Sensor Project – Arduino Uno

Moisture Sensor Project – Arduino Uno

In this project students are to set up a moisture sensor to detect the moisture of soil in a potted plant.This will now alert you when the soil moisture drops below 60%. For setting up this project you will need the following products.


What you need for the project

Arduino Uno
Moisture sensor FC 28 with LM 393 Comparator (The sensor in the image is different from the FC 28, this is only used for setting up the circuit diagram using Fritzig.)
Breadboard
An LED light of your choice
3 Jumper cables to connect to the VCC, A0, D0, GND
VCC: For Power
A0: Analog output
D0: Digital output
GND: Ground

We will only be using VCC, A0 and GND

Code for set up.
Open your arduino sketch copy and paste the code below

Upload the code and you are good to go.

 

Code
____________________________________________

/*
Soil Moisture Data Collection
*/

int LED= 13; //This is the digital pin that the LED is connected
//which will blink when the moisture is low

void setup(){
Serial.begin(9600);
pinMode(LED,OUTPUT);
}

void loop() {
int sensorReading= analogRead(A0); //reads the analog sensor value

Serial.println (sensorReading); //prints out the sensor reading

if (sensorReading > 800){//if reading is above 800, LED blinks on and off
digitalWrite(LED,HIGH); //turns the LED on
delay(1000); //waits for a second
digitalWrite(LED,LOW); //turns the LED off
delay(1000); //waits for a second
}
}

____________________________________________

The code used  is indicated above

Before you determine the values, which may be different for your sensor. Make sure after connecting the set up to determine the lowest and highest values from the serial monitor
The highest value is when the sensor is completely dry, which means there is no moisture.
Now immerse the sensor is water, to determine the highest moisture content. This reading is the lowest value that you will see in the serial monitor.
Divide the difference, and determine the value needed to trigger the LED to light up when the moisture level goes below a certain value. If the value is between 300 and 1023 you may use 800 as a trigger value. It all depends on the sensor you have, and your need.
If everything works well the LED will light up when you take it off from the water.

Arduino Uno Moisture sensor project
Arduino Uno