Wednesday, May 29, 2024

Automatic Drip Irrigation System

Conventional irrigation method wastes a lot of water, leading to a high cost of electricity to run the pump set for irrigation. Automation can help save water, electricity as well as human efforts. This can be achieved with the help of a single soil-moisture sensor and an AVR microcontroller. Here we present an automatic drip irrigation system that senses the moisture level of the soil and automatically switches the pump on when the power is ‘on.’

Automatic drip irrigation system circuit

Circuit of the automatic drip irrigation system is shown in Fig. 1. It has three sections: sensor, microcontroller and water-pump motor circuits.

Circuit of automatic drip irrigation system
Fig. 1: Circuit of automatic drip irrigation system

The sensor circuit detects soil condition by measuring the soil voltage and comparing it with a reference voltage. A BC548 transistor is used to drive relay RL1. DC motor pump M1 is connected between the normally-open (N/O) pin and pole of the relay.

If the soil is dry, i.e., the ground voltage is greater than the reference voltage, the microcontroller (ATmega16) gives a logic-1 output signal. The transistor conducts to energise relay RL1 (as its pole pin comes in contact with the N/O pin) and the motor turns on with power supply provided from the battery.

When the soil is wet, i.e., soil voltage is less than the reference voltage, the logic-0 signal of the microcontroller turns the transistor, and hence the motor switches ‘off.’
The motor pump status (‘on’ or ‘off’) and soil condition (‘dry’ or ‘wet’) are displayed on LCD1.

- Advertisement -

Fig. 2 shows the author’s prototype with the moisture sensors embedded in the soil to be monitored.

Author’s prototype watering the plant in a flower pot
Fig. 2: Author’s prototype watering the plant in a flower pot
Author’s prototype indicating the motor status in wet soil condition
Fig. 3: Author’s prototype indicating the motor status in wet soil condition


The software was developed using four tools: CodeVisionAVR, Proteus, SinaProg and PCB Wizard.


The coding and hex file were generated using the Evaluation version of CodeVisionAVR tool. In CodevisionAVR, open a new project and select ‘Target AVR Chip’ as ATmega. Select the ATmega16 chip with 8MHz clock frequency, followed by output port as Port B0. Then select ‘ADC Enabled’ option and set voltage reference as AREF pin with 1000kHz clock. Next, select ‘Enable Alphanumeric LCD Support’ option followed by Port C (PC0-RP6) with 16 characters.

- Advertisement -

In ‘Program’ menu, select ‘Generate, Save and Exit’ option. Save the file three times with the same name but different extensions as indicated by the software. In the coding window, start code within the while loop to read the sensor output signal at AD0 pin of the microcontroller. Next, put a condition if reference voltage 2V is greater than or equal to the sensor signal. Then build the entire project file to produce the hex file.


Open Proteus simulation tool, create a new file, then open the library and select the required components (Fig. 4). To simulate the code, double-click the controller (U1) and insert the hex file. Simulation runs when the sensed voltage is higher than the reference voltage (2V). The LCD shows that the soil is dry and the motor is ‘on.’ When the sensed voltage is less than the reference voltage, the LCD shows the soil as ‘wet’ and the motor as ‘off.’

Proteus simulation without DC motor
Fig. 4: Proteus simulation without DC motor


USBasp is a USB in-circuit programmer for Atmel AVR controllers, similar to AVRuPro+ board. It consists of an ATMega88 or an ATMega8 and a few passive components. The programmer uses a firmware-only USB driver, requiring no particular USB controller. It is used along with SinaProg software to burn the hex file into the controller.


SinaProg software is used to burn the hex code and set fuse bits for the AVR microcontroller. It is a good software tool for hobbyists and experimenters alike. Connect the AVR USB programmer such as USBasp to your PC. Load the hex code, select the device programmer and set the fuses (Int.2MHz) as shown in Fig. 7.

PCB Wizard

PCB Wizard is used to design the circuit board. Open the tool and select the required components from the PCB component gallery. (You can also use any other PCB designing tool such as open source software gEDA.)

parts list

Construction and testing

An actual-size PCB layout of the automatic drip irrigation system is shown in Fig. 5 and its components layout in Fig. 6. After assembling the circuit, enclose it in a suitable box.

PCB layout of automatic drip irrigation system
Fig. 5: PCB layout of automatic drip irrigation system
Components layout for the PCB
Fig. 6: Components layout for the PCB

Download PCB and component layout PDFs: click here

Download source code

First, program the microcontroller with the hex code and place it on the PCB. Connect the moisture sensor to the circuit, ensuring that Vcc, GND and D0 pins are properly connected. Note that the moisture sensor includes YL-38 and YL-69 modules. YL-38 is basically a driver and isolator for YL-69 moisture probe (Fig. 8). YL-38 has four pins (Vcc, GND, D0 and A0) on one side, and two pins on the other side, which are used to connect the prongs/probes (YL-69) that are to be inserted into the soil. D0 pin is used for digital output and A0 pin (not used in this project) is used for analogue output. The module also has a potentiometer to calibrate the sensitivity of the sensor.

SinaProg window
Fig. 7: SinaProg window
Prongs with driver
Fig. 8: Prongs with driver

Connect a 9V battery to the circuit. Regulator IC 7805 provides regulated 5V output to run the circuit. Note that you can also use a 12V DC power supply depending on your motor pump. During testing at EFY Lab, a 12V DC supply was used for the water motor pump.
To test the project, insert the sensor probe into the soil. Switch on the power supply to the circuit. If the soil is dry, the motor will automatically turn on and the LCD will show ‘Dry soil, Motor on’ message.

You can further extend this project to make a practical drip irrigation system. Typically, a drip irrigation system requires some special components and control systems. For example, you may need distribution lines (both large- and small-diameter pipes and pipe fittings), electronic or hydraulic control valves, poly fittings and accessories (to make connections), emitters, drippers or spray heads depending on the design and application.

Feel interested? Check out this list of electronics projects.



Unique DIY Projects

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components