element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Robotics
  • Technologies
  • More
Robotics
Forum Automatic irrigation system using pic microcontroller
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Robotics to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 22 replies
  • Answers 15 answers
  • Subscribers 65 subscribers
  • Views 5067 views
  • Users 0 members are here
Related

Automatic irrigation system using pic microcontroller

akashm.m
akashm.m over 7 years ago

Any one pls tell me how to build a automatic irrigation system using pic microcontroller. & It's programming

  • Sign in to reply
  • Cancel

Top Replies

  • gadget.iom
    gadget.iom over 7 years ago in reply to jw0752 +9 suggested
    I totally agree with what jw0752 is saying here. The community is very supportive, and your experiences will help others far more than you might immediately think. Where other on-line communities might…
  • jw0752
    jw0752 over 7 years ago in reply to urkraft +7 suggested
    Hi Raymond, I have to disagree with you a little. Everyone who has ever made anything NEW has been through the same process as you have described. I respect you for your in process posting of your results…
  • mcb1
    mcb1 over 7 years ago in reply to urkraft +7 suggested
    Am quite sure that is the problem. Adding hysterisis to the relay will help stop it destroying itself. This is one of the biggest advantages of adding any form of controller BUT it can be achieved by capacitors…
  • ntewinkel
    0 ntewinkel over 7 years ago in reply to urkraft

    >I guess it could be perceived as overkill to use an Adafruit Feather HUZZAH ESP8266 for something as banal as this

     

    I was thinking of using a Digistump Oak (similar to Huzzah I think), just to check pond water levels, heh. It's the wireless and web-based part that really makes life easier. I supported his Kickstarter, and haven't really used it since originally trying it out.

     

    That said, there's something about building circuits that do not use a microcontroller that adds to the fun of the challenge too.

     

    -Nico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • beacon_dave
    0 beacon_dave over 7 years ago in reply to urkraft

    Yes, very likely.

     

    Adding a hysteresis resistor to the LM393 comparator circuit should have tamed its D0 switching behaviour for driving the relay though e.g.

    http://www.ti.com/lit/ug/tidu020a/tidu020a.pdf

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • urkraft
    0 urkraft over 7 years ago in reply to beacon_dave

    Thank you Dave,

     

    Been racking my mind trying to remember that work (hysteresis) - it's been at least 30 years since i last used it (studied electronics in the 70's and have not been very active with it the last 3 decades)! Am quite sure that is the problem.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • urkraft
    0 urkraft over 7 years ago in reply to ntewinkel

    Yes, i agree with you Nico, but unfortunately i am not very talented and have lots of things i am interested in and not enough time to touch on a fraction of them - so i have to make some difficult decisions about prioritizing. I love programming passionately and its attraction can be too great for me to resist image.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • urkraft
    0 urkraft over 7 years ago

    My latest attempt at a solution:

    I just wasted about 1 hour documenting my work in this blog when everything was suddenly lost, so i have no intention of wasting more time in this way. This is going to be a "quick and dirty" posting. If this attempt also fails then i will give up.

     

    Parts used:

    • 1 Adafruit Feather HUZZAH ESP8266
    • 1 5v 1A DC power supply w/micro usb contact for the HUZZAH
    • 1 12v 1A DC power supply (https://www.kjell.com/no/produkter/elektro-og-verktoy/stromforsyning/stromforsyning/ac-dc/fast-utgangsspenning/ac-dc-stromadapter-12-v-(dc)-12-w-p44382)
    • 1 power jack for the 12v power supply
    • 1 soil moisture sensor (https://www.kjell.com/no/produkter/elektro-og-verktoy/arduino/moduler/luxorparts-jordfuktmaler-p87941)
    • 1 22k ohm 1/8w resistor
    • 1 10k 1/8w resistor
    • 1 33 ohm 1/4w resistor
    • 2 1N4001 diodes
    • 1 Peristaltic Pump (https://www.kjell.com/no/produkter/elektro-og-verktoy/elektronikk/electromechanics/motorer/luxorparts-vaeskepumpe-peristaltisk-p90782)
    • 1 VR05R241A single pole DIL relay (https://www.kjell.com/no/produkter/elektro-og-verktoy/elektronikk/electromechanics/releer/1-polet-dil-rele-5-v-dc-0-5-a-30-v-p36110)
    • 1 Breadboard
    • Jumber wires
    • Water container w/water

     

    Schematic Drawing:

    image

    Solid State Relay Datasheet:

    image

    HUZZAH code:

    #include <ESP8266WiFi.h>

     

     

    const char* ssid     = "<your ssid here>";

    const char* password = "<your password here>";

     

     

    const int LED = 0;

    const int PUMP = 4;

    // Max value is approx. 825 - bone dry

    // Min value is approx. 406 - drowning in water

    const int THRESHOLD = 700;

    int moisture = 0;

    int tmp = 0;

     

     

    void setup() {

      // put your setup code here, to run once:

      Serial.begin(115200);

      delay(100);

     

     

      Serial.println();

      Serial.println();

      Serial.print("Connecting to ");

      Serial.println(ssid);

     

      WiFi.begin(ssid, password);

      // supstitute the ipaddresses below with your desired static ip, router ip, and dhcp ip

      WiFi.config(IPAddress(192, 168, 1, 50), IPAddress(192, 168, 1, 1), IPAddress(192, 168, 1, 1));

     

      while (WiFi.status() != WL_CONNECTED) {

        delay(500);

        Serial.print(".");

      }

     

     

      Serial.println("");

      Serial.println("WiFi connected");

      Serial.println("IP address: ");

      Serial.println(WiFi.localIP());

     

     

      Serial.println();

      Serial.println();

      Serial.println("Soil moisture sensor");

      pinMode(PUMP, OUTPUT);

      pinMode(LED, OUTPUT);

      digitalWrite(LED, HIGH);

      digitalWrite(PUMP, HIGH);

    }

     

     

    void loop() {

      // put your main code here, to run repeatedly:

      tmp = analogRead(A0);

      if (tmp != moisture) {

        moisture = tmp;

        Serial.print("moisture = ");

        Serial.println(moisture);

        if (analogRead(A0) > THRESHOLD) {

          digitalWrite(LED, LOW);

          digitalWrite(PUMP, LOW);

          Serial.println("Threshold reached - water the plant!");

        } else {

          digitalWrite(LED, HIGH);

          digitalWrite(PUMP, HIGH);

        }

      }

      delay(1000);

    }

     

    Comments:

    Everything appears to be stable with this solution so far. In the future i plan on implementing the following changes:

    - sensor to detect when the water supply is empty

    - send email when detected that water supply is empty, and do not attempt to pump water if the water supply is empty

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • urkraft
    0 urkraft over 7 years ago in reply to urkraft

    Forgot to mention a couple of other changes i plan to make to the code:

     

    - Introduce another (lower) threshold and use it for turning off the water pump

    - introduce a longer time delay (1 day) to wait before checking soil moisture immediately after turning off the pump.

     

    These changes will have to wait as i have other activities pending which require my immediate attention.

     

    -raymond

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • mcb1
    0 mcb1 over 7 years ago in reply to urkraft

    Am quite sure that is the problem.

    Adding hysterisis to the relay will help stop it destroying itself.

     

    This is one of the biggest advantages of adding any form of controller BUT it can be achieved by capacitors, resistors and a dose of imperical derivation.

     

    I have an organic Irrigation controller ... my wife turns on the sprinkler for her garden.

    Mark

    • Cancel
    • Vote Up +7 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • urkraft
    0 urkraft over 7 years ago in reply to mcb1

    Thank you Mark,

     

    I do believe that you are right. I have used hysteresis via code in the version of this project that i posted yesterday - among other changes that i have implemented. All testing so far appear to indicate that everything is working as planned and expected.

     

    Congratulations on your organic irrigation controller image!

     

    - raymond

    ludo ergo sum!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • urkraft
    0 urkraft over 7 years ago

    By the way - i plan on posting all future developments in my irrigation project here: (Semi)Automated Plant Irrigation System

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • ntewinkel
    0 ntewinkel over 7 years ago in reply to urkraft

    I was just thinking it would be nice to have all this information in a blog post you (Raymond) own, as you've been providing most of the content on this post.

     

    ps, the original poster has not been seen since asking the question - I bet it was a question for a school or college project image

     

    -Nico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
<>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube