Automatic plant Irrigation using a PIC12F675 microcontroller.

Published by MKDas on

Irrigation is important for our farms whatever it is on large scale or on a small scale. Due to lack of rain and water flow, lots of crops damage each year. Even in your 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 that you can make within 30 minutes and set up the system in your plant and travel outside for weeks without any tension. So let’s start our Automatic Plant Irrigation using a PIC12F675 microcontroller.

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

Effect of water in soil:

Dry soil is not conductive in manner. But a little bit of water in the 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. It’s your choice. But I’ll suggest making 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 a copper wire what we use for coils/inductors.

Copper wire

Just cut in the length of 15-20 cm. Then remove the insulation using sandpaper or the 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 using a small microcontroller PIC16F675. A micro-controller will make the total job easy. Although an Op-Amp will work fine too. But little hassle may arise.


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 highly rated, select a suitable relay or another 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 of what you need. Let’s see the circuit diagram of this project.

Circuit diagram:

The circuit diagram of Automatic Plant Irrigation using a PIC12F675 is very easy. Here is the diagram:

Circuit diagram

Working principle:

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

Using the ADC module of the micro-controller we can measure the voltage at the 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.


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
      adc_rd += ADC_Read(0);
   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
}//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 our Automatic Plant Irrigation using a PIC12F675. Here is the design.

PCB for irrigation project

Download the PCB file from here.

Also, read PWM solar charge controller using PIC12F675 microcontroller.

Practical testing:

I made this project in PCB. But at that time, I forgot to take some images of that project. So I rearranged the project on 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!


I'm Mithun K. Das; B.Sc. in EEE from KUET, Bangladesh. Blog: "First, electronics was my passion, then it was my education, and finally, electronics is now my profession." I run my own electronics lab, M's Lab ( Where I work with the creation of new products from ideas to something in real life. Besides this is my personal blog where I write for hobbyists and newcomers in the electronics arena. I also have a YouTube channel where I publish other helpful videos, you can find the link inside the articles. I always try to keep it simple so that it becomes easy to understand. I hope these will help them to learn electronics and apply the knowledge in their real life.


Godwin · July 13, 2021 at 7:18 pm

Hex file is no longer existing, please try and upload it again , sir

    MKDas · July 14, 2021 at 1:34 pm

    Download again. Total project file uploaded.

Leave a Reply

Avatar placeholder

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