Easy Irrigation Project with PIC12F675 in 30 minutes

Published by MKDas on

Irrigation is important for our farms whatever it is in large scale or in small. Due to lack of rain and water flow, lots of crops damage each year. Even in you home plant pots need to do regular irrigation to keep your plants alive. In this article we will learn to make an automated irrigation system which you can make within 30 minutes and setup the system in your plant and travel outside for weeks without any tension….

Disclaimer: Electricity is always dangerous. Skill required to work with electricity. Do work with your own risk. Author will not be responsible for any misuse or harmful act. This website contents is also copyright protected. Anything copied and directly posted in your website and claiming it as yours is prohibited and nonsensical. Author published all the articles as opensource to help you making your project and learning purpose only. Learn and make one for yourself. If need any help feel free to ask the author. Author will be helpful to you. Thanks.

Effect of water in soil:

Dry soil is not conductive in manner. But little bit of water in soil makes it conductive in electronic behavior. That means, if we measure conductivity with a resistance meter, we’ll get high resistance in dry soil. But we’ll get low resistance in wet.

Soil Moisture sensor

Working Concept of automated irrigation system:

So, all we need to do is to measure the soil conductivity. Based on conductivity we can identify if the soil is wet or dry. If the soil is dry, we will turn on a water pump which will supply water to the soil. When the soil gets wet, we’ll turn that water pump off. It is the concept of our project. Now we have to make everything in line sequentially.

What we need for this project?

For this project we need these components/modules

  1. Soil moisture sensor
  2. A controller to control operation
  3. Water pump
  4. Switching device to turn the water pump on/off
  5. Plastic pipes.

Making a soil moisture sensor:

You can buy a soil moisture sensor or you can make one. Its your choice. But I’ll suggest to make one because, there is no such rocket science behind a soil moisture sensor that you can not do yourself.

All you need two pieces of copper wire what we use for coils/inductors.

Copper wire

Just cut in length of 15-20 cm. Then remove the insulation using sand paper or bold side of a knife. Then cover the whole copper wire with solder lead using a soldering iron. This will reduce corrosion.

Solder connecting wire in one side of each copper wire and cover that with tapes. Just like a test probe of multi-meter.

Select a controller to operate the circuit:

You can use Op-Amp for this purpose but I’ll suggest to use a small micro-controller PIC16F675. A micro-controller will make the total job easy. Although an Op-Amp will work fine too. But little hassle may arise.

PIC16F675

Datasheet of PIC16F675.

Select a Water pump for our project:

Any water pump you can select for this project. Anyone will work fine. Depending on your pump selection, the switching device will be changed.

Switching device for your pump:

Depending on your pump rating, a switching device can be selected. The most common device will be a relay. You can use common 12V relays for this purpose. But if your pump is high rated, select suitable relay or other device according to the pump ratings.

A commercial relay

Collect some plastic pipes:

Collect some plastic pipes according to your pump in/out head’s diameter. Few meters of these pipes may work fine for your pump:

Flexible plastic pipes

Now you’ve arranged most of the supplies and have got an idea what you need. Let’s see the circuit diagram of this project.

Circuit diagram:

Circuit diagram of this project is very easy. Here is the diagram:

Circuit diagram

Working principle:

As you can see, here we used PIC12F675 micro-controller as our controller. A relay is used for switching purpose and test probes are connected to AN0 (GP0 pin) of the micro-controller.

Using the ADC module of micro-controller we can measure the voltage at AN0/GP0 pin. This voltage will be high if the soil is dry and will be low if the soil is low. After a trial, we can select at which voltage we can set our set-points.

Transistor BC547 is used to operate the relay which is actually turning the pump on/off.

12V & 5V power supply is made with a transformer, bridge diode, capacitor and voltage regulator LM7805.

Coding:

Here to code the micro-controller, I used mikroC pro for PIC. You can download the file and use the hex only if you do not have the compiler.

/*******************************************************************************
*                    Program for, "Automatic Irrigation System"                *
*                       Code Written by_ Engr. Mithun K. Das                   *
*                          MCU: PIC12F675; X-Tal: 4MHz(in)                     *
*                                  Date: 03-10-2018                            *
*******************************************************************************/
unsigned int adc_rd=0,i=0;
#define        Wet_LED      GP5_bit
#define        Dry_LED      GP4_bit
#define        Pump         GP2_bit
void main() 
{
 TRISIO = 0b00000001;// GP0 input only
 GPIO = 0x00;//clear port
 CMCON = 0x07;//Comparator off
 ANSEL = 0x01;//AN0 analog input
 ADCON0 = 0x01;//AN0 channel selected
 while(1)
 {
   for(i=0;i<10;i++)
   {
      adc_rd += ADC_Read(0);
      Delay_ms(100);
   }
   adc_rd/=10;//get avg value
   
   if(adc_rd<800)// wet?
   {
      Wet_LED = 1;// Wet LED on
      Dry_LED = 0; // Dry LED off
      Pump = 0;//pump off
   }
   else if(adc_rd>900)
   {
      Wet_LED = 0;// Wet LED off
      Dry_LED = 1; // Dry LED on
      Pump = 1;//pump on
   }
 
 }//while(1)
}//void main

Code is very simple and small. I think you can understand it easily.

You can download the mikroC file from here. or

You can download the .hex file from here.

PCB diagram for this project:

You can make the PCB for this project. Here is the design.

PCB for irrigation project

Download PCB file from here.

Practical testing:

I made this project in PCB. But on that time, I forgot to take some images of that project. So I rearranged the project in a project board here.

Auto irrigation system

I hope you enjoyed the project and you made one for yourself. If you need any help, feel free to ask me. Thank you, Enjoy!


MKDas

Mithun K. Das; B.Sc. in EEE from KUET. Blog: https://labprojectsbd.com

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *