zinc Posted July 9, 2018 Author Share Posted July 9, 2018 Cheers @doobie01 will take a look when i am next in there. Haven't seen any in there before though. Maybe it is just the one local to me doesn't stock or i am being blind! @Inspiration101 This is the code i have so far for original idea, very simplistic so far. So far basically a loop which checks the current moisture level against the high and low set points and sets Pot value to match. If the value is not above or below these set points it will hold the previous value until one of the conditions is met. Still need to work more on timings and look at creating some internal looping and figure the best way to only have the system active while lights are on. Sensor= power to turn on sensors PotXin= current moisture values PotXmax = Max set point PotXmin = Minimum set point (turn on value) PotXvalue = the current value being used to water/not water //Sensor Power digitalWrite (Sensor, HIGH); delay (5000); //Set Value if above maximum if (analogRead(Pot1in)>Pot1setmax){ Pot1value = analogRead(Pot1in); } if (analogRead(Pot2in)>Pot2setmax){ Pot2value = analogRead(Pot2in); } if (analogRead(Pot3in)>Pot3setmax){ Pot3value = analogRead(Pot3in); } if (analogRead(Pot4in)>Pot4setmax){ Pot4value = analogRead(Pot4in); } //Set Value if below minimum if (analogRead(Pot1in)<Pot1setmin){ Pot1value = analogRead(Pot1in); } if (analogRead(Pot2in)<Pot2setmin){ Pot2value = analogRead(Pot2in); } if (analogRead(Pot3in)<Pot1setmin){ Pot3value = analogRead(Pot3in); } if (analogRead(Pot4in)<Pot1setmin){ Pot4value = analogRead(Pot4in); } digitalWrite (Sensor, LOW); //Water if (Pot1value<Pot1setmin){ digitalWrite (Pot1out, HIGH); delay (1000); digitalWrite (Pump, HIGH); delay (5000); digitalWrite (Pump, LOW); delay (1000); digitalWrite (Pot1out, LOW); } delay (5000); if (Pot2value<Pot2setmin){ digitalWrite (Pot2out, HIGH); delay (1000); digitalWrite (Pump, HIGH); delay (5000); digitalWrite (Pump, LOW); delay (1000); digitalWrite (Pot2out, LOW); } delay (5000); if (Pot3value<Pot3setmin){ digitalWrite (Pot3out, HIGH); delay (1000); digitalWrite (Pump, HIGH); delay (5000); digitalWrite (Pump, LOW); delay (1000); digitalWrite (Pot3out, LOW); } delay (5000); if (Pot4value<Pot4setmin){ digitalWrite (Pot4out, HIGH); delay (1000); digitalWrite (Pump, HIGH); delay (5000); digitalWrite (Pump, LOW); delay (1000); digitalWrite (Pot4out, LOW); } delay (1800000); //30 minute 1 Link to comment Share on other sites More sharing options...
Inspiration101 Posted July 9, 2018 Share Posted July 9, 2018 //Set Value if below minimumif (analogRead(Pot1in)<Pot1setmin){ Pot1value = analogRead(Pot1in);}if (analogRead(Pot2in)<Pot2setmin){ Pot2value = analogRead(Pot2in);}if (analogRead(Pot3in)<Pot1setmin){ Pot3value = analogRead(Pot3in);}if (analogRead(Pot4in)<Pot1setmin){ Pot4value = analogRead(Pot4in);}digitalWrite (Sensor, LOW); ======================================== Highlighted in red, the two in blue need changing to 3 & 4 ? 1 Link to comment Share on other sites More sharing options...
zinc Posted July 9, 2018 Author Share Posted July 9, 2018 Yes @Inspiration101. Well spotted. Damn copy and paste! 1 Link to comment Share on other sites More sharing options...
Inspiration101 Posted July 9, 2018 Share Posted July 9, 2018 Will the sensor stay live all the time ? I think this is best for the sake of wear and tear of the sensor itself. Best on than flip flopping. Wrapping it all up inside one big loop should be straight forwards enough, is there a command for just sending it back to the start ? Calling the first function again or just a simple GOTO command ? What you have created looks tip top, good effort ! Link to comment Share on other sites More sharing options...
zinc Posted July 9, 2018 Author Share Posted July 9, 2018 @Inspiration101 I was planning to use resistive sensors which degrade when they are powered, so was trying to do this to try to keep on time to a minimum. Capacitive seem the better option though which would make things better. It is all in a loop at the minute, but could put in a separate loop that if a pot has been watered previously to decrease the loop time to 5 minutes or other things. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now