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

BUILDING CIRCUIT

Here we connected Pins describe below

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

 

Arduino pin Soil Sensor
VCC VCC
GND GND
8 D0

 Make circuit connection as shown.

soil sensor with arduino in digital mode

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 button, here output of sensor’s digital pin will be read at pin 8 of 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. Threshold value of sensor can be varied by varying resistance value through potentiometer (variable resistor/ POT) present on at sensor module.

Leave a Reply

avatar
  Subscribe  
Notify of

Arduino Tutorials with Basic Electronics: CONTENT

Translate »