SOIL SENSOR WITH ARDUINO IN DIGITAL MODE

What is soil sensor  (moisture sensor FC-28 ) and how it works you can read in our previous topic which is SOIL SENSOR WITH ARDUINO IN ANALOG MODE. Here now we will see how to use Soil Sensor with Arduino in Digital Mode and to control led as an output.

Brief: 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 and digital mode. We will see interfacing in both modes of the sensor.

REQUIRED HARDWARE FOR SOIL SENSOR WITH ARDUINO IN DIGITAL MODE

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 digital mode

CONNECTION TABLE

Arduino pin LED
13 Anode (+)
GND Cathode (-)

 

Arduino pin Soil Sensor
VCC VCC
GND GND
8 D0

MOISTURE SENSOR ARDUINO CODE – IN DIGITAL MODE

int led_pin = 13;
int sensor_pin = 8;
int sensor_output;

void setup() {
  pinMode(led_pin, OUTPUT);
  pinMode(sensor_pin, INPUT);
}
void loop( ) {
  sensor_output = digitalRead(sensor_pin);
  if (sensor_output == HIGH) {
    digitalWrite(led_pin, HIGH);
  }
  else {
    digitalWrite(led_pin, LOW);
  }
  delay(1000);
}

OUTPUT

This is same as reading the state of the button, here the output of sensor’s digital pin will be read at pin 8 of the arduino and stored in variable sensor_value, as we know digital signal can be 1 (HIGH) or 0 (LOW), then we compare read signal if read signal is high then turn on led high if signal read as low turn off led connected at 13. 

The threshold value of the sensor can be varied by varying resistance value through a potentiometer (variable resistor/ POT) present on the sensor module.


READ NEXT
ULTRASONIC SENSOR WITH ARDUINO


Total Visits: 915
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x