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.
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.
Fig. 2 shows the author’s prototype with the moisture sensors embedded in the soil to be monitored.
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.
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.’
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 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.)
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.
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.