Project showcase
Sump Pit Alarm

Sump Pit Alarm © GPL3+

Homegrown sump pit monitor with Nagios integration.

  • 2,745 views
  • 5 comments
  • 14 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
10167 01
DHT22 Temperature Sensor
Temp and humidity sensor not critical to this build, but I figured why not?
×1
51gzz5eu9pl. sx425
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Lite on ltl 1che
3 mm LED: Red
Red LED was salvaged from a malfunctioning strand of Christmas lights.
×1
Lite on ltl 1chg
3 mm LED: Green
Green LED was salvaged from a malfunctioning strand of Christmas lights.
×1
Adafruit industries ada1536 image
Buzzer
Buzzer was salved from a broken remote control car.
×1
2" PVC pipe
×1
2" PVC pipe coupling
×1
2" PVC pipe clean-out with lid
×1

Necessary tools and machines

09507 01
Soldering iron (generic)
Wire cutters/stripper

About this project

Background

I woke up at 6 am on the morning of my most recent birthday to a steady rain falling outside, eventually thinking to myself "you know, I don't think I've heard my sump pump run in a while." It had been a very wet and rainy couple of weeks up here in the northeast, too. After dashing downstairs through my wife's freshly built basement office and tearing off the pit lid, my fear was confirmed. The water level was nearly at the top of the pit, well above the point where the pump should have kicked on. I quietly wished myself a happy (milestone) birthday, and then swiftly ushered off to the local Ace hardware store to purchase a new sump pump.

Knowing that I had gotten lucky this time and not wanting to rely on luck again, I decided to build my own sump pit water level sensor/alarm and integrate that into my Nagios monitoring server for email/text message alerts. Sure, I could have just bought some sort of commercial alarm, but it would likely not have had all the features for which I was looking and would have been grossly over-priced. Hence I started on my journey.

The Build

The guts of the monitor is an Arduino UNO with an HC-SR04 distance sensor. The HC-SR04 is mounted in a 2" PVC pipe that runs through the pit lid. I mounted it inside a pipe in order to protect the sensor from water splashing onto it, for obvious and various reasons. The sensor is connected with 4 wires from a CAT5e cable.

I traced the inside diameter of the pipe onto an old unused DVD case and I cut out holes for the sensor to sit on. When the clean-out is glued into the coupling, it locks the plastic mount into place. The sensor actually sits in the coupling portion and the clean-out allows me to easily access the wiring/sensor while also protecting it.

The clean-out is glued to the coupling and the coupling is mounted onto a PVC pipe. I did not glue the coupling onto the pipe because I wanted to be able to remove the entire clean-out/coupling component in the event I ever have to replace the sensor. The pipe is meant to be a semi-permanent fixture in the sump pit.

I used some expired red Sugru that I had laying around to create my own gasket which also serves to stabilize the pipe.

I didn't want to just rely on Nagios email/text alerts, just in case there was an issue with an SMTP daemon crashing or whatever, so I also added a set of LEDs - one red and one green - that provide alerting redundancy in the form of visual feedback. These were clipped and salvaged from a busted set of Christmas lights. They are hot-glued/mounted in a "common" area in the basement for ease of viewing.

Obviously the lights don't do any good if you aren't walking through the space, so I added one final piece of alerting redundancy and that is in the form of a buzzer.

Where the wiring all comes together is ugly - I admit. The board mount is also primitive. I would have preferred a nice plastic box where I could route wires, but that didn't happen. I chose to re-saw a 1/4" strip of some scrap 2x3s on my bandsaw and then mount all the components onto it. The mount is zip-tied to my computer rack.

All the GNDs/- are wired/soldered together and then protected with a crimp cap. The constant 5v+ are also soldered/crimped together. I did this because I didn't have enough connections on the board itself. It's not elegant by any means.

Final Note

One final note here on the HC-SR04 sensor: I wasn't sure how accurate/consistent it would perform in a pipe like this, so I setup a test rig with a fixed distance and just let it run while I collected the data for analysis. I gathered over 75,000 data samples and I found it was outside the acceptable range (+/- 2CM) on less than .03% of the readings.

24 / 75516 = 0.00031781344351
0.00031781344351 = .03%

.03% error is good enough for me in this case.

Code

Pit Sensor CodeArduino
// $Rev::                         $:  Version of last commit
// $Author::                      $:  Author of last commit
// $Date::                                                $

#include <DHT.h>;

// DHT22 sensor setup
#define DHTPIN 13
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

// pin setup
const int trigPin = 7;
const int echoPin = 8;
const int buzzerPin = 9;
const int redLed = 11;
const int greenLed = 12;

//Variables
float hum;
float temp;
long duration;
int distance;

void setup() {
  // HC-SR04
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  // LEDs
  pinMode(greenLed, OUTPUT);
  pinMode(redLed, OUTPUT);
  // Buzzer
  pinMode(buzzerPin, OUTPUT);
  //
  Serial.begin(9600); // Starts the serial communication
  dht.begin();
}

void loop() {
  // <---------------- HC-SR04 ------------------------->
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  // 10000ms is 10 seconds
  // 2000 ms is 2 seconds
  delay(5000);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance in cm
  distance = duration*0.034/2;

  // <---------------- DHT22 ------------------------->
  // Read data and store it to variables hum and temp
  hum = dht.readHumidity();
  temp = dht.readTemperature();
  // Print temp and humidity values to serial monitor
  // Convert C to F
  temp = temp * 9/5 + 32;
  // Output
  Serial.print(temp);
  Serial.print("|");
  Serial.print(hum);
  Serial.print("|");
  Serial.println(distance);

  // <-------------- LEDs + buzzer ------------------------>
  if (distance <= 20)
    {
      digitalWrite(redLed, HIGH);
      digitalWrite(buzzerPin, HIGH);
      digitalWrite(greenLed, LOW);
    }
  else
    {
      digitalWrite(greenLed, HIGH);
      digitalWrite(redLed, LOW);
      digitalWrite(buzzerPin, LOW);
    }
}
Nagios Plug-inPython
#!/usr/bin/env python

# $Rev::                         $:  Version of last commit
# $Author::                      $:  Author of last commit
# $Date::                                                $

import serial
import re
import sys

try:
    ser = serial.Serial('/dev/ttyACM0', 9600, timeout=15)
    ser.close()
    ser.open()

    rawSensorOutput = ser.readline().rstrip('\n')

    x = re.split('\|', rawSensorOutput)

    temp = float(x[0])
    hum = float(x[1])
    dist = int(x[2])

    if dist >= 31:
        print "SUMP PIT OK - %s cm from top; temp - %s, hum - %s" % (dist, temp, hum)
        sys.exit(0)
    elif dist <= 30:
        print "SUMP PIT CRITICAL - %s cm from top; temp - %s, hum - %s" % (dist, temp, hum)
        sys.exit(2)
    else:
        print "SUMP PIT UNKNOWN"
        sys.exit(3)

except (OSError, serial.SerialException):
    print "SUMP PIT CRITICAL - Cannot open serial port"
    sys.exit(2)

Schematics

Pit Sensor Diagram
Wiring connections are missing.
pit_sensor_diagram_YYUWzhMoUh.fzz

Comments

Similar projects you might like

Sump Pump Monitor and Alarm

Project showcase by JoSain

  • 1,247 views
  • 1 comment
  • 7 respects

Motion Sensing Alarm With Keypad & Password

Project showcase by thehack904

  • 8,789 views
  • 27 comments
  • 33 respects

Entry Level Door Monitoring Alarm System

Project tutorial by Robodia Technology Solutions

  • 6,416 views
  • 1 comment
  • 18 respects

Buzzer Alarm System With Help Of Arduino

by Team ONYX

  • 37,887 views
  • 5 comments
  • 21 respects

A Very Compact Alarm with Card Reader and Real-Time Clock

Project tutorial by Simone Adobs

  • 5,976 views
  • 3 comments
  • 30 respects

Arduino DIY Alarm

Project showcase by Team Robert's Robot

  • 1,838 views
  • 2 comments
  • 4 respects
Add projectSign up / Login