If you’re coming up with your own intelligent “GreenHouse” with an facultative digital plant moisture sensor/water pump controller that lights an LED to alert the user once it’s time to water a potted plant, and/or activate a pump to quench the thirst, here is an Arduino Primer for you.

No doubt, an Arduino will convert your favorite pots into self-watering planters, keeping your plants from drying out and reducing the time you spend watering. Self-watering system is good for individuals often on vacation, and takes the idea out of watering. Plants draw up wetness as they have it!

Hardware

The hardware consists of an Arduino microcontroller (here an Arduino Uno R3) and a pre-wired soil moisture detector module. The soil moisture detector module, designed round the LM393 comparator, offers an active-low (L) level output once the soil is dry (determined by a pre-setted threshold value). This digital output (wet soil → L / dry soil → H) is routed to 1 I/O terminal (D2) of the Arduino microcontroller. Supported this input (at D2) arduino offers an active-high (H) output through D13 once soil is dry, and an active-low (L) output once soil is wet.

(soil moisture sensor module)

Software

This “demo” code here will simply be an equivalent as alternative consistent programs. This code controls the LED connected to pin D13 in reference to the input level on Pin D2. D13 output may be accustomed enable/disable a water pump/similar controller electronic equipment.

Arduino

1

2

3

4

5

6

7

8

9

10

11

12

13

14

#define IND_OP 13

#define SEN_IN 2

voidsetup(){

pinMode(IND_OP,OUTPUT);

pinMode(SEN_IN,INPUT);

}

voidloop(){

if(digitalRead(SEN_IN)==HIGH){

digitalWrite(IND_OP,HIGH);

}else{

digitalWrite(IND_OP,LOW);

delay(1000);

}

}

Hook Up Note

The +5V route (VCC) of the module is coupled to the 5V line of the Arduino. GND of the module is that the common (0V) affiliation. The digital signal output to be detected (usually marked as neutralize the module) is applied to D2 input of the Arduino. Analog output (marked as AO) from the module isn’t used here. Sensor-head of the module contains 2 probes in a very little metal PCB. Once the sensor-head is inserted in wet soil, moisture bridges the probes through a low-resistance path (when soil is dry, resistance between the probes is additionally high). A potentiometer is enclosed within the module for adjusting the soil wet/dry detection sensitivity in keeping with actual necessities.

Analog Link

It is conjointly possible to read the number of moisture present within the soil (for deciding whether or not the soil is wet or dry) by linking the analog output (AO) of the module, to 1 analog input (A0) of the Arduino. Here is the test code that indicates the soil wet/dry conditions using simply 2 LEDs (green & red).

Arduino

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

intGLED=13;// Wet Indicator at Digital PIN D13

intRLED=12;// Dry Indicator at Digital PIN D12

intSENSE=0;// Soil Sensor input at Analog PIN A0

intvalue=0;

voidsetup(){

Serial.begin(9600);

pinMode(GLED,OUTPUT);

pinMode(RLED,OUTPUT);

Serial.println("SOIL MOISTURE SENSOR");

Serial.println("-----------------------------");

}

voidloop(){

value=analogRead(SENSE);

value=value/10;

Serial.println(value);

if(value<50)

{

digitalWrite(GLED,HIGH);

}

else

{

digitalWrite(RLED,HIGH);

}

delay(1000);

digitalWrite(GLED,LOW);

digitalWrite(RLED,LOW);

}

Zero – Arduino Try Out

From the circuit diagram of the module, it’s clear that, except for the module solely some external parts are required to make a relay-driver circuit. Yes, there’s an opportunity to understand one easy non-arduino project of a forgetful plant waterer! If you’re searching for this feature, digital output of the module should be connected to the tiny circuit shown below, and use an external 5V DC power supply.

If higher current loads are to be driven a PNP semiconductor can be superimposed to the module’s digital output. Here the addition of 2N3906 semiconductor controls an electro-magnetic relay (RL1) for driving high-current/high voltage loads like pump motors through its N/C contacts (when soil is wet, relay remains in energised state).