Automatic watering system with Arduino for your plants, orchard or garden

Watering can watering plants

Summer is a time when many people go on holiday outside and plants are a problem, as you can’t water those days when you’re not at home. In addition, garden shops usually sell a kind of gel that allows you to hydrate and nourish the plant for about a month. But in the heat of the day or if you go away for more than a month, then you will need a somewhat better system so that when you return they will still be alive and vigorous.

To make that possible, the solution is to buy an automatic irrigation system that you can program or if you are a maker and you like DIY, you can do it yourself with Arduino. The materials you need, apart from the Arduino board, are easy to find and quite cheap, so they don’t cost too much. Also, for some items like the water tank, etc., you could use recycled materials…

If you surf the net a little you will find several projects of this type, but perhaps the most interesting is Jarduino. I will take inspiration from that for this project, since I consider that other irrigation systems that only use humidity sensors and nothing else are not so complete.

What do you need?

The materials needed for your automatic irrigation system are

  • Arduino ONE plate, although others would be worthwhile.
  • Protoboard or PCB if you want to solder it and make it permanent.
  • Temperature and humidity sensor DHT11
  • Cables
  • soil moisture sensor with hygrometer to stick in your pot(s) or soil.
  • of submersible water of 3V and approximate flow of 120 l/h.
  • Diode
  • Bipolar transistor
  • 3 Resistances: 1x 220 ohms, 1x 1k, 1x photoresistor LDR
  • Water tank, which can be a drum or a bottle of 5 or more liters, etc.
  • Tube to be connected to the mini-pump and taken to the plant(s)

As an alternative idea, I would say that you could also use a sonoff or a WiFi module to activate it over the Internet from wherever you are, or improve it by adding an automatic valve to the tap to program the filling of the water tank when it empties, etc.

How to install the automatic irrigation system

Fritzing assembly diagram

The assembly is quite simple. You can use the diagram above to make all the connections. You will need to position your system close to the window or where the plant you want to water is located and stick the two tips of the moisture sensor into the soil of the plant, near the stem.

The automatic irrigation system with Arduino will water whenever it detects a series of environmental conditions. For example, when it detects low light or darkness, the air temperature is a specific one that we will set in the Arduino IDE sketch, and the smoke on the ground is low. At that time it would activate the motor to water the plant.

Remember that you must introduce the mini pump under water in the tank that you have destined for irrigation, and that it should have a sufficient capacity to endure the days that you are not there. You can pre-test it to see how long it lasts and you should leave a little more water in case it evaporates in the intense heat…

Remember that you must insert the mini pump under water in the tank you have designated for irrigation, and that it should have a sufficient capacity to withstand the days you are away. You can make previous tests to know how long it lasts and you should leave a little more water in case it evaporates with the intense heat .

No need to say that the tube should be fixed to the plant so that it does not move with the wind or the water can fall out and be wasted. And I don’t think you have to remember that you have to maintain a power supply to the Arduino plate for it to work…

Programming

Now you must write the necessary code in Arduino IDE to be able to program the microcontroller that manages the hardware you have used. Here is the time to adapt the temperature, humidity and light values suitable for watering in your area, as they may vary depending on where you are. But the example you can use as a base is (I have left comments where you could modify the values, the rest you can leave it like that):


#SimpleDHT.h
#include <SPI.h
#define humidity_sensor_pin A0
#define ldr_pin A5
//B Libraries for used sensor modules needed
//Y definition of variables for humidity and LDR sensors on A0 and A5 pins

int pinDHT11 = 2;
SimpleDHT11 dht11;
int ldr_value = 0;
int water_pump_pin = 3;
int water_pump_speed = 255;
// Here you can give values from 0 to 255 for the speed at which the mini-pump will work
// Pre-test the flow rate and set the. I have // chosen 255 but you can choose the one you want. The higher the speed, the more // water pumping
void setup() {
  Serial.begin(9600);
}
void loop() {
// Measures the temperature and relative humidity and displays the result
  Serial.println(“*******************************”);
  Serial.println("Sample DHT11...");
  
  byte temperature = 0;
  byte humidity_in_air = 0;
  byte data[40] = {0};
  if (dht11.read(pinDHT11, &temperature, &humidity_in_air, data)) {
    Serial.print ("DHT11 sensor reading failed");
    return;
  }
  
  Serial.print("Show RAW Bits: ");
  for (int i = 0; i < 40; i++) { Serial.print((int)data[i]); if (i > 0 && ((i + 1) % 4) == 0) {
      Serial.print(' ');
    }
  }
  Serial.println("");
  
  Serial.print("Sample OK: ");
  Serial.print("Temperature: ");Serial.print((int)temperature); Serial.print(" *C, ");
  Serial.print("Relative humidity in air: ");Serial.print((int)humidity_in_air); Serial.println(" %");
  
  int ground_humidity_value = map(analogRead(humidity_sensor_pin), 0, 1023, 100, 0);
  Serial.print("ground_humidity_value: ");
  Serial.print(ground_humidity_value);
  Serial.println("%");

  int ldr_value = map(analogRead(ldr_pin), 1023, 0, 100, 0);
  Serial.print("Light: ");
  Serial.print(ldr_value);
  Serial.println("%");
   Serial.println(“*******************************”);

//**************************************************************
// Watering conditions
// If the humidity in the soil is equal to or less than 60%, if the luminosity is less than 30%,
// If the temperature is below 35%, then the irrigation system waters.
// If any or all of the 3 above requirements are not met,
// the irrigation system does not water
//**************************************************************
// Here you can vary the parameters you need from 60, 35 and 30, and even use other operands .
 if( ground_humidity_value <= 60 && ldr_value<30 & temperature<35) {
 digitalWrite(water_pump_pin, HIGH);
 Serial.println("Irrigation");
 analogWrite(water_pump_pin, water_pump_speed);

 }
 else{
 digitalWrite(water_pump_pin, LOW);
 Serial.println("Watering stopped");

 }
 delay (2000);
// Runs the code every 2000 milliseconds, that's 2 seconds. You can vary the sampling frequency
}

Sources

More about DHT11

More information – Jarduino

Leave a Comment

*

*