Building an Arduino-Based Automatic Irrigation System With a Soil Moisture Sensor

by CircuitDigest in Circuits > Arduino

506 Views, 3 Favorites, 0 Comments

Building an Arduino-Based Automatic Irrigation System With a Soil Moisture Sensor

SMS-image.jpg

If you're thinking about setting up a smart irrigation system or an automatic plant watering system, the soil moisture sensor is a crucial component. By integrating this sensor with Arduino, we can create an automated irrigation system that waters plants only when necessary, preventing both overwatering and underwatering. In this guide, we'll walk through the process of interfacing a soil moisture sensor with Arduino to measure the volumetric concentration of water in the soil. 

Supplies

Components:

  1. Arduino Uno
  2. Soil moisture sensor module
  3. Breadboard
  4. Jumper wires
  5. LED (optional)
  6. Potting soil
  7. Plant

Understanding the Soil Moisture Sensor

Soil-Moisture-Sensor-Pinout.png

The soil moisture sensor, also known as the soil humidity sensor, features four pins: VCC, GND, Aout, and Dout. These pins facilitate the retrieval of soil moisture data from the sensor:

  • VCC: Power supply pin, connectable to either 3.3V or 5V supply. Note that the analog output varies depending on the supplied voltage.
  • GND: Ground pin, connected to the Arduino's ground pin.
  • Dout: Digital output pin; low output indicates appropriate soil moisture, while high indicates low soil moisture.
  • Aout: Analog output pin, providing an analog signal between VCC and ground.

How Does a Soil Moisture Sensor Work?

Soil-Moisture-Sensor-Module.jpg

The operation of the soil moisture sensor is straightforward. The fork-shaped conductive probe is inserted into the soil, featuring two exposed conductive plates that act as a variable resistor. The resistance of the probe is inversely proportional to the soil moisture: more water in the soil leads to better conductivity and lower resistance, while less water results in higher resistance. The sensor produces an output voltage corresponding to the resistance, allowing us to determine the moisture level.

Connect the Circuit:

Analog Output:

Connect the sensor's VCC and GND pins to the Arduino's 5V and GND pins, respectively.

Connect the sensor's analog output (Aout) pin to the Arduino's A0 pin.

Digital Output:

Connect the sensor's VCC and GND pins to the Arduino's 5V and GND pins, respectively.

Connect the sensor's digital output (Dout) pin to the Arduino's digital pin 7.

Upload the Arduino Code:

The code reads the analog data from the sensor and adjusts the brightness of the LED (if connected) or triggers an action (like controlling a water pump) based on the moisture level. You can find the code here,and adapt it to your specific needs.

Circuit Diagram

Soil-Moisture-Sensor-Module-Circuit.png

The soil moisture sensor module schematic and Arduino code are provided for reference. The schematic illustrates a simple circuit using an LM393 op-amp to convert the analog signal from the sensor probe into a digital signal. The Arduino code reads the analog data from the sensor and adjusts the LED brightness accordingly.


Test and Calibrate:

  • Place the sensor probe in the moist soil of your plant pot.
  • Upload the code to your Arduino.
  • Observe the LED behavior (if connected) or monitor the serial output for analog values.
  • Adjust the code's threshold values if needed to trigger actions at desired moisture levels.

Additional Notes:

  1. Sensor placement is crucial. Ideally, place it at one-third to two-thirds the depth of the plant's root zone.
  2. Consider using a relay module to control a water pump based on the sensor readings.
  3. Explore advanced techniques like controlling watering based on other factors like temperature and humidity.

By following these steps, you can build your own automatic irrigation system and ensure your plants receive the right amount of water. Remember to adapt and personalize this guide based on your specific needs and project requirements.

Working Demo

How to use Soil moisture Sensor with Arduino

A demonstration of the soil moisture sensor in action showcases how the LED intensity changes based on soil moisture levels. Adding water to the soil increases the LED intensity, indicating higher moisture levels.