I've set up an Arduino Uno to run a pretty basic garden watering schedule, with the delay function.
I've now built a solar thermal water heater with a pump and tried running it separately through a 555 timer using a thermistor (33k Ohm approx). I couldn't get this running as the change in resistance with a water temperature rise to 30 deg or so wasn't enough to trip and untrip the 555 timer (thermistor at about 20 k at 20 deg, maybe 50k at 30 deg). (Any pointers to circuits that achieve this would be appreciated by the way.)
I've decided to try to run the solar thermal motor with my arduino set up as I have 2 relays free in a relay shield. My question is how I can run the sensor to start the solar thermal pump, then stop operating the solar thermal system and return to the garden watering code, then restart the sensor input, and so on. The issue is that my power supply is only 1 Amp, and running both systems at once might overheat it.
Hope this makes sense, Brian
-
Is the watering system running off the same relay board?RSM– RSM2016年07月07日 07:27:07 +00:00Commented Jul 7, 2016 at 7:27
2 Answers 2
If you are just running the relays off the 1 Amp supply, and there aren't more than 6 relays they shouldn't draw more than an amp.(I will edit this statement if need be)
What you can do in the way of coding you can is to do a classic spinoff of using the millis()
function.
//monitors temperature and schedules its operations
//RSM
#define TimeBetweenHydration 10000 //10 seconds
#define TimeBetweenThermal 1000 //1 second
#define Temperature_Thresh 25 //25°C
float temperature = 0.00;
unsigned long lastTempReadTime = 0; //keep track of the time temperature was checked
//boolean MotorOn = false; //state monitoring
unsigned long lastWaterTime = 0; //last time the system did something with the watering thing
//boolean Watering = false; //state monitoring
// other variables related to specifics
//...
//
void setup(){
//setup of analog inputs
//setup of digital pins
}
void loop(){
unsigned long presentTime = millis();
if((presentTime - lastTempReadTime) > TimeBetweenThermal){
lastTempReadTime = presentTime;
int inADC = analogRead(0);
//do whatever conversion is needed to get a value of the temperature
temperature = inADC*3.14;
if(temperature > Temperature_Thresh){
// if(!MotorOn){
digtalWrite(RLY, HIGH); //turn on pump
// MotorOn = true;
// }
}
else{
digitalWrite(RLY, LOW); //turn off pump
}
}
if((presentTime - lastWaterTime) > TimeBetweenHydration){
lastWaterTime = presentTime;
//put your watering code stuff here
}
}
If you want to make the pump run without a microcontroller you could use a comparator with the thermistor and use its output to switch a transistor. I do not have the 555 timer art skills.
thermistor controls with comparator
T1 is you thermistor. You should use the values listed for R1 - R3. The transistor, coil and flyback diode are there to show how you should connect it up, the coil could be a motor or a relay to control the motor. The comparator changes around the 30-40Kohm mark.
-
In your schematic one leg of the relay coil (the one connected to the anode of the diode) connects to the transistor. I think the other leg of the relay coil (the one connected to the cathode of the diode) is missing a connection to +VCC (5v).linhartr22– linhartr222016年07月07日 17:42:58 +00:00Commented Jul 7, 2016 at 17:42
-
@linhartr22 yes it is missing the connection to 5V, 12V. The OP wasn't specific about there way the relays were hooked up and I didn't have a way to mark that with what I was using.RSM– RSM2016年07月07日 20:11:51 +00:00Commented Jul 7, 2016 at 20:11
-
1RMS, you are some man. I tracked down not an LM393, but an LM2904 and it took me a while, but it's working like a dream. Response time is great, and what a classy solution.Brian O Callaghan– Brian O Callaghan2016年07月08日 23:32:37 +00:00Commented Jul 8, 2016 at 23:32
-
@BrianOCallaghan glad the circuit helped you, I think at a point certain things can be removed from the control of the microcontroller and code ;). If you feel this solved the query, could you mark it as accepted to stop the system from bumping it and to help others looking for a solution.RSM– RSM2016年07月09日 06:24:52 +00:00Commented Jul 9, 2016 at 6:24
I really appreciate your answer, thanks. I knew I'd have to let go of the delay function at some stage, and this is the moment I think ;)
As for the PS, I'm actually also powering two solenoid valves and the arduino through the same PS, so just being on the safe side.
I wasn't too happy with a transistor circuit I made previously, but I'll give yours a go for sure. I actually came up with a workaround, which is probably pretty lame. I rigged up a second 555 timer with a large resistor to switch on and off the supply to the first 555 with thermistor every minute or so (a la flashing LED). So the thermistor now goes to temp, switches on the load, but then won't switch it off; the second 555 then resets the first 555, load switches off and either immediately switches on again if at temp, or stays off. Pretty ugly, right!
-
The rig with the 555 timer sounds pretty good actually, you have made something that the code I did work in hardware.RSM– RSM2016年07月07日 12:56:26 +00:00Commented Jul 7, 2016 at 12:56