Table of Contents
Here we are going to interface a Soil sensor with Arduino (moisture sensor FC-28 ). This sensor measures the moistness content of water in the soil and gives us the moisture or dryness level as output. The sensor is prepared with both analog and digital outputs, so it can be used in both analog mode and digital mode. We will see interfacing in both modes of the sensor. But here in Analog Mode.
CLICK HERE FOR SOIL SENSOR WITH ARDUINO IN DIGITAL MODE DIGITAL
WORKING OF SOIL MOISTURE SENSOR
The soil moisture sensor consists of two probes that are immersed in soil to measure the moistness content of water. Current passes from one probe to reach another probe through/via soil and then it gets the resistance value which is then calibrated and we get moisture level.
When there is more water (moisture level will be higher), the soil will conduct more electricity which means that there will be less resistance.
Dry soil conducts electricity poorly, so when there will be less water (moisture level will be lower), then the soil will conduct less electricity which means that there will be more resistance.
As soil moisture sensor can be used in both modes analog and digital. Let first connect it in Analog mode and then we will use it in Digital mode.
PINOUT – SOIL MOISTURE SENSOR
The soil Moisture sensor FC-28 has four pins
- VCC: For power
- A0: Analog output
- D0: Digital output
- GND: Ground
The Module also contains a potentiometer (variable resistor) which is used to set the threshold value and then this threshold value will be compared by the LM393 comparator. The output LED will light up and turn off according to this threshold value.
SOIL SENSOR WITH ARDUINO – IN ANALOG MODE
REQUIRED HARDWARE
S.No. | Item | Quantity |
1 | Arduino Uno | 1 |
2 | Soil Sensor with Comparator | 1 |
3 | LED | 1 |
4 | Resistor 220 ohm | 1 |
5 | Male to Male jumper | 5 |
CIRCUIT DIAGRAM
CONNECTION TABLE
Arduino pin | LED |
13 | Anode (+) |
GND | Cathode (-) |
Arduino pin | Soil Sensor |
VCC | VCC |
GND | GND |
A0 | A0 |
MOISTURE SENSOR ARDUINO CODE IN ANALOG MODE
int sensor_pin = A0; int output_value ; void setup() { Serial.begin(9600); Serial.println("Reading From the Sensor ..."); delay(2000); } void loop() { output_value = analogRead(sensor_pin); delay(200); //output_value = map(output_value, inputLow, inputHigh, outputLow, outputHigh); output_value = map(output_value, 0, 1023 , 10, 550); output_value = map(output_value, 550, 10, 0, 100); Serial.print("Moisture : "); Serial.print(output_value); Serial.println("%"); delay(1000); }
CODE EXPLANATION
//output_value = map(output_value, inputLow, inputHigh, outputLow, outputHigh);
/*
map function gives us some mathematical computing and returns a value. Computations like assign input range and map them to take output in other ranges. For example, I want to map numbers of a student into percentage. If the maximum number can be 1000 then its input range is 0-1000 and percentage will be the output so its range will be 0-100.
Map function requires 5 parameters.
1st variable which value to be computes, here number
2nd variable lower bound of input range i.e. 0 (numbers 0-1000)
3rd variable upper bound of input range i.e. 1000 (numbers 0-1000)
4th variable lower bound of output range i.e. 0 (percentage 0-100)
5th variable lower bound of input range i.e. 100 (percentage 0-100)
So, if the number of a student is 400, it will give us 40 as output which we can consider as a percentage.
*/
/*
As we are using analog mode input range will be 0 – 1023 and its output range will be the moisture sensor data which can be from 10-550 (wetness to dryness, 550 is 100% dryness or 0% moisture and 10 is 0% dryness or 100% moisture)
*/
/*
After doing this we have an input range of 10 to 550, now we want to convert this values in percentage moisture so this time we’ll map input 550-10 (we can map in reverse directions well) because we want moisture content as a mapping result from 0 – 100 % not the dryness content.
*/
OUTPUT
READ NEXT
SOIL SENSOR WITH ARDUINO IN DIGITAL MODE
3319 12417a great deal lately with my father so hopefully this will get him to see my point of view. Fingers crossed! mortgage banker new york 538323
659999 157793superb post. Neer knew this, appreciate it for letting me know. 43225
759125 423520Hi my loved one! I want to say that this article is wonderful, excellent written and incorporate almost all vital infos. I would like to peer much more posts like this . 655412
541156 638026Thanks for the post. I like your writing style – Im trying to start a blog myself, I feel I may possibly read thru all your posts for some suggestions! Thanks once a lot more. 990456
969572 565936Some genuinely good stuff on this website , I it. 704565
137071 695540when i was a kid, i love to receive an assortment of birthday presents like teddy bears and mechanical toys, 977438
892147 964962I dugg some of you post as I thought they were extremely beneficial invaluable 967865
269943 435473Hi there! I just wish to give an enormous thumbs up for the good information youve proper here on this post. I shall be coming again to your weblog for extra soon. 255710
214948 542156Oh my goodness! an incredible post dude. Thanks a ton However We are experiencing problem with ur rss . Dont know why Cannot enroll in it. Can there be any person locating identical rss dilemma? Anyone who knows kindly respond. Thnkx 101865
475039 76327The the next occasion Someone said a weblog, Hopefully so it doesnt disappoint me approximately this. What im saying is, I know it was my choice to read, but I really thought youd have something interesting to express. All I hear is often a number of whining about something that you could fix in the event you werent too busy looking for attention. 85238