Anyone know of a good argument to use for this project?

My family has a hunting ranch with a cabin in Texas which is located 5 hours from our home. The cabin has a well setup with a electric pump, we shut off the water to the cabin before we leave via valve but we keep water on to a giant water ‘bucket’ which the deer and other local animals drink from. The bucket has a mechanical float valve which closes when full.
However, it can be risky leaving this on when temperatures drop to freezing and we often leave the ranch unattended for sometimes months at a time. I just had to drive up here just to turn the well pump off since temperatures are expected to hit -1F on Monday and we don’t want a pipe to burst and flood the area. It doesn’t happen often but I would like to set up a automated system that will shutoff the well pump should temperatures drop to 30f.
The way I would like this system to function is if it hits 30f pump shuts off, once temperatures hit 45f again and a certain amount of time has passed possibly, the pump turns back on, but after hitting 30f once the pump only runs 20 min. a day until it is physically reset regardless of temperature in case of a busted pipe.
I would also like to use two temperature sensors as a failsafe in the event one sensor differs greatly from the other sensor then I would like the system to be overridden and the pump be toggled on regardless or at least 30min.-1 hour a day.

I have personally done a few Arduino projects and have a general idea how to do the bulk of this code but once I start thinking of how to include the more customized parts of this code my mind goes blank and I fear I would have to go about this code in a entirely different way.
This isn’t my actual code but more of a general idea, I haven’t done any projects recently and I have poor internet right now out in the country so I’m gonna type up my general idea off the top of my head, I’m sure everything will be wrong but it should get the general idea out there.

If sensorx <= 30f then
digitalWrite(PinA,low)
delay(172,800,000){ensures pump stays off for at least two days after reaching 30f}
else if sensorx >=45f
Digital Write(PinA,high)

Okay, so I know this doesn’t look like anything close to code but using “IF” arguments are what I am most familiar with from previous projects and are what I tend to rely on but I can’t think of a way to use them in the way I want to unless I give up a lot of customization and make the project much more simple. I also plan to add a bypass switch in case someone happens to be at the cabin during cold weather which I believe I can just list as the first ‘IF’ argument and override everything.

I’m sure someone has a much better way to go about this.

Why are you starting a new post ?

larryd:
Why are you starting a new post ?

I am assuming the reason you are asking this is because I posted something similar regarding the same project in the general electronics section in which I asked for recommendations for a reliable temperature sensor for this application?
I now need help getting started with the code and with what arguments I might use to help solve my specific operating needs. I figured help with programming and code belongs in the programming questions and recommendations on temp. sensors belong in the general electronics section. I didn't want to start asking for help with the coding in the general electronics section cause then I would have at least a few users tell me to post it here.

the main idea is to use two thresholds, one for switcing off and the other for re-engaging.

For the delay, you better use the "blink without delay" approach.

But, I think your problem is much more complex. For example, if the water in tank (or the surface) freezes, then perhaps you get with a destroyed floater.

I think, despite the use of an automation as you think it or not, you must install a timer device (on the same arduino or independent) to "allow" power to pump only for (let say) half an hour per day at noon (higher temp).

I suppose the general idea is fine, but i wouldn't be using delay() to make sure the pump doesn't turn on and off all the time, as if it would... where would the 15 degrees temperature increase come from ? But i would use a millis() based system, or you won't be able to override the temperature switch for 2 hours after it has shut off.

Do some research on state machines, that would be how I would implement this, since the desired operation changes considerably depending on previous conditions. You would also likely need to save some information in eeprom in case the power fails or the arduino resets, and use of the watch dog timer would also be a good idea.

If practical, a pressure sensor on the water line would help in detecting a broken pipe, a simple on/off type sensor would work, since all you need is to detect if you are getting full water pressure when the float valve is closed and there is little to no water flow.

Well, I already posted this code/update but it doesn’t look like it went through or it got deleted somehow, anyway I decided to go with a ds18b20 temp. sensor thanks to a recommendation. I already got the bulk of the code written up, it’s not the perfect solution but should be good enough.

#include <OneWire.h>
#include <DallasTemperature.h>

const int TEMP_THRESHOLD_UPPER = 27; // upper threshold of temperature
const int TEMP_THRESHOLD_LOWER = 2; // lower threshold of temperature

const int SENSOR_PIN    = 2; // Arduino pin connected to DS18B20 sensor's DQ pin
const int RELAY_PUMP_PIN = 3; // Arduino pin connected to relay which is connected to pump
int inPin = 4; //Toggle switch for override for whenever someone is at the cabin in temperatures below 80.6f
int val = 0;

OneWire oneWire(SENSOR_PIN);         // setup a oneWire instance
DallasTemperature sensors(&oneWire); // pass oneWire to DallasTemperature library

float temperature;    // temperature in Celsius

void setup()
{
  Serial.begin(9600); // initialize serial
  sensors.begin();    // initialize the sensor
}

void loop()
{
  sensors.requestTemperatures();             // send the command to get temperatures
  temperature = sensors.getTempCByIndex(0);  // read temperature in Celsius
val = digitalRead(inPin);   // read the input pin
  if(temperature > TEMP_THRESHOLD_UPPER){// If temperature is greater than 80.6f, well pump stays on
    Serial.println("The pump is turned on");
    digitalWrite(RELAY_PUMP_PIN, LOW); // turn on pump
  } else if (val = HIGH)//If toggle switch is is the on position, relay gets overriden and pump is turned on, for when the cabin is occupied.
    { Serial.println("The pump is turned on");
    digitalWrite(RELAY_PUMP_PIN, LOW); // turn on pump
  }
  else if(temperature < TEMP_THRESHOLD_LOWER){// If temperature drops below 35f pump turns off
    Serial.println("The pump is turned off");
    digitalWrite(RELAY_PUMP_PIN, HIGH); // turn off pump
  } 
  else    
  //If temperature is between 35 and 80.6f, pump is on a timer and runs for 30min. everyday
    
   { digitalWrite(RELAY_PUMP_PIN, LOW); // turn on pump
    Serial.println("The pump is on a timer");
    delay(300000); //5 minute delay to fill up animal water source
    digitalWrite(RELAY_PUMP_PIN, HIGH); // turn off pump
    delay(14400000); //4 hour delay to pause water pump
  }
  delay(500);
}

GRuser:
the main idea is to use two thresholds, one for switcing off and the other for re-engaging.

For the delay, you better use the “blink without delay” approach.

But, I think your problem is much more complex. For example, if the water in tank (or the surface) freezes, then perhaps you get with a destroyed floater.

I think, despite the use of an automation as you think it or not, you must install a timer device (on the same arduino or independent) to “allow” power to pump only for (let say) half an hour per day at noon (higher temp).

I’m not sure if I’m following you 100% here. As far as running it 30 min. a day, as long as it’s above freezing 30f. it should be fine. If it’s below 35f the pump should not turn on with the code. If it’s still on a 4 hour delay when it starts to go below 35f well then it’s still not below freezing yet and it has already filled the bucket for 5 min. beforehand so no damage done. But, I agree, blink without delay would be better. I live in Texas so it doesn’t freeze like this very often, It was somewhat unpleasant to have to accompany a family member on a 5 hour drive with dangerous road conditions just to turn off a water pump. I prefer to avoid this in the future and have fun doing it.

Deva_Rishi:
I suppose the general idea is fine, but i wouldn’t be using delay() to make sure the pump doesn’t turn on and off all the time, as if it would… where would the 15 degrees temperature increase come from ? But i would use a millis() based system, or you won’t be able to override the temperature switch for 2 hours after it has shut off.

I didn’t take into consideration the effect delay would have on the bypass switch, I guess you could use the bypass switch and then hit reset on the nano, but might as well do it right the first time and make it perform better/cleaner.

05silgto:
I'm not sure if I'm following you 100% here. As far as running it 30 min. a day, as long as it's above freezing 30f. it should be fine. If it's below 35f the pump should not turn on with the code. If it's still on a 4 hour delay when it starts to go below 35f well then it's still not below freezing yet and it has already filled the bucket for 5 min. beforehand so no damage done. But, I agree, blink without delay would be better. I live in Texas so it doesn't freeze like this very often, It was somewhat unpleasant to have to accompany a family member on a 5 hour drive with dangerous road conditions just to turn off a water pump. I prefer to avoid this in the future and have fun doing it.

about the timer : clarification : Suppose you need 100lt per day. Suppose your pump can deliver 100lt in half an hour. Then If All conditions to run pump are ok, run it for not more than about half an hour OR until fill up (whichever comes first) (ie dont wait ONLY to fill up, there may be a broken pipe)

I got more information on why it's important to turn off the pump at freezing temperatures and apparantly it not just to do with a broken pipe. My family can easily fix a broken pipe. The problem is if a pipe bursts and it leaks 24/7 then the well will eventually run dry. If this were to happen the pump would run dry and then burn out. The pump happens to be 365 feet below ground. You can imagine the costs of having a company come out to the middle of nowhere with large machinery just to dig up a water pump.
Running 30 min. A day in temperatures between 35 and 80f would keep the well wet even in the event of a leak. I might even add a longer timer during the summer for extra security.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.