Automatic Sump Pump

This was not a complex project. In fact, it probably took 30 minutes of AC wiring, and 5 minutes of writing Arduino software. But the point to be made is that it was a hugely useful project.

As part of my well leak detection project, I ended up needing to do some plumbing work in one of those concrete boxes sunk into the ground. Because there had been a leak for, oh, maybe a year, the ground was saturated and the box would keep filling with water, making it hard to work in there. I owned an old sump pump, but it was not automatic, so I would pump the ground out, work for a bit, and then pump it out again, repeat. That got old pretty quick. It made me think that there had to be a better way.

And of course, there was!

It occurred to me that if I added another length of garden hose to my sump pump discharge outlet, I could throw the end of the second hose down a hillside about 50 feet away. By getting the end of the discharge hose lower than the pump, I would have a siphon. Starting the sump pump would prime the siphon. Once the siphon was primed, I could shut the pump off and the siphon would finish draining the water in the pit. I tried that, and it worked beautifully. But it was still a manual process. Then it occurred to me that if I took an Arduino, connected it to a solid state relay to control the pump, I could have the Arduino periodically enable the pump for long enough to prime the siphon, at which point it all became automatic. If by some miracle there was not enough water needing to be pumped to start the siphon, I could be sure that running the pump for only 15 seconds every 3 minutes wouldn't harm it. I put it all together, and it worked great.

That's all of it, above: a pretty simple system. One GPIO to drive a solid state relay left over from the toaster oven reflow project using the wiring box left over from the current sensor project. Project reuse is a good thing.

Hey kids, don't touch those hot 120VAC wires! Not to worry, I put a plastic trash can lid over top of everything for complete safety.

Here is the entire Arduino source:

// Run the sump pump periodically for a certain amount of time
uint32_t last_cycle_time_ms;

const uint32_t pump_run_time_ms = 15000;                        // Run for 15 seconds...
const uint32_t cycle_interval_ms = ((uint32_t)1000 * 60 * 3);   // ...every 3 mins

void cycle_pump(uint32_t run_ms)
{
  // Sample the time now so that it is not affected by the run-time
  last_cycle_time_ms = millis();
  
  digitalWrite(10, LOW);    // SSR 'on'
  delay(run_ms);
  digitalWrite(10, HIGH);   // SSR 'off'
}

void setup() {
  pinMode(10, OUTPUT);
  
  // Always cycle the pump once at startup, then periodically after that
  cycle_pump(pump_run_time_ms);
}

void loop() {
  uint32_t now = millis();
  if ((now - last_cycle_time_ms) > cycle_interval_ms) {
    cycle_pump(pump_run_time_ms);  
  }
}