SOIL SENSOR WITH ARDUINO IN ANALOG MODE

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 moisture sensor

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

soil sensor with arduino in analog mode

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

soil moisture sensor output


READ NEXT
SOIL SENSOR WITH ARDUINO IN DIGITAL MODE


 

Total Visits: 2445
5 1 vote
Article Rating
Subscribe
Notify of
guest
38 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
تعمیر کولر گازی جنرال
تعمیر کولر گازی جنرال
9 months ago

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

tattered flag tailgate decal
tattered flag tailgate decal
9 months ago

659999 157793superb post. Neer knew this, appreciate it for letting me know. 43225

poker99
poker99
9 months ago

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

안전바카라
안전바카라
9 months ago

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

Realtor
Realtor
9 months ago

969572 565936Some genuinely good stuff on this website , I it. 704565

homes for sale
homes for sale
9 months ago

137071 695540when i was a kid, i love to receive an assortment of birthday presents like teddy bears and mechanical toys, 977438

cialisis
cialisis
9 months ago

892147 964962I dugg some of you post as I thought they were extremely beneficial invaluable 967865

qiuqiu99
qiuqiu99
9 months ago

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

mejaqq pkv
mejaqq pkv
9 months ago

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

rajawaliqq
rajawaliqq
9 months ago

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

duratrans printing nyc
duratrans printing nyc
9 months ago

678757 316613Yours is a prime example of informative writing. I feel my students could learn a lot from your writing style and your content material. I might share this article with them. 966509

business consulting
business consulting
9 months ago

593390 84378quite good post, i certainly adore this site, go on it 776566

klikdokter
klikdokter
9 months ago

696447 401681Naturally I like your web-site, even so you need to check the spelling on several of your posts. Several of them are rife with spelling troubles and I find it quite silly to inform you. On the other hand I will certainly come again once more! 144188

www.rajaqqhoki.club
www.rajaqqhoki.club
9 months ago

492352 959203As a result youll need ultra powerful online enterprise suggestions to keep operating in acquiring into matters correct your incredible web-based work. MLM 875501

Alivia
Alivia
9 months ago

489218 499505Seriously quite good contribution, I truly depend on up-dates of your stuff. 369425

wayangpoker
wayangpoker
9 months ago

227184 710925actually great post, i definitely love this website, keep on it 265594

Street Paper
Street Paper
9 months ago

811174 237848Im so pleased to read this. This is the kind of manual that needs to be given and not the accidental misinformation thats at the other blogs. Appreciate your sharing this very best doc. 899546

affiliate clickfunnels
affiliate clickfunnels
9 months ago

840096 558499Hello Guru, what entice you to post an write-up. This article was incredibly interesting, specially since I was searching for thoughts on this topic last Thursday. 726444

aff-casino
aff-casino
9 months ago

976541 985949Straight towards the point and effectively written! Why cant everybody else be like this? 794952

카지노
카지노
9 months ago

286909 627234I like this web site really significantly so much great information. 548202

38
0
Would love your thoughts, please comment.x
()
x