Any one pls tell me how to build a automatic irrigation system using pic microcontroller. & It's programming
Any one pls tell me how to build a automatic irrigation system using pic microcontroller. & It's programming
>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
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.
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.
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 .
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:
Schematic Drawing:
Solid State Relay Datasheet:
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
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
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
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 !
- raymond
ludo ergo sum!
By the way - i plan on posting all future developments in my irrigation project here: (Semi)Automated Plant Irrigation System