I have been asked by a very good friend who is now wheelchair bound to build a fully automated watering system, simple enough I thought, I have been building electronic projects for years now so this can’t be that hard, trouble is, I have not had to get into code writing before, apart from simple batch files for dosbox, the only other stuff like this I have had to deal with was in the early days of linux but that was just tracking libraries down and compiling stuff nothing like writing code yourself.
So, I have managed to work out what hardware i need:
Arduino mega
1 x 8 relay board
1 x 2 relay board
1 x display
1 x pump
9 x moisture sensors
1 x temp sensor
1 x flow meter
10 x solenoid controlled valves
11 way manifold
lots of pipe
and many many wires
simple system description
pump in water tank goes to manifold which has 10 solenoid controlled outlet valves, 9 valves outlet to plants 1 valve has return pipe to tank, all valves controlled by relay board, each plant has water sensor.
The idea is this, the first action for the system is to open valve 10 (return to tank pipe attached) and then activate the pump for 20 seconds to make sure system charged, then it turn off the pump and closes the valve, then it goes through a cycle where it checks each plant moisture sensor and if the sensor on a plant is saying dry then the appropriate valve opens and the pump is activated for a predetermined time, then the valve is closed and the next plant moisture sensor is checked and so on.
The temp sensor is to monitor feed tank, a water heater may be added later.
The flow meter is only to be activated when in the watering cycle and not a system charge cycle, this is to keep an eye on usage and on a charge cycle the water is not being used.
I have an Arduino mega 2560 and I have an 8 relay module and a moisture sensor that has it’s own little board with it that has 2 pins to the sensor and 4 pins to the Arduino, Ihave managed to wire this up and managed to get it to print the readings from the pins in the serial monitor in the official sketch software so I know it’s working ok
I have also managed to get the relays to connect to the arduino and all of them be off upon boot, then i have managed to get them to turn on and off again.
What I need to know is how do I get the sensor to trigger the relays I don’t seem to be able to get my head round getting the two to work together. I know i need in code a way of saying when the value of analog input 1 is say 400 then digitalWrite(RELAY1, LOW); but if analog input 1 is greater than 400 then digitalWrite(RELAY1, HIGH); but I can’t get it right, so it is time to ask someone who knows.
If there is someone out there who can point me in the right direction i would be most pleased, I will learn with your help.
sensor in plant pot registers plants state, when moist then leave and check next plant sensor, if