Sump Pump Diagnostics, Alerts, and Monitoring

by Mike520 in Circuits > Raspberry Pi

20 Views, 0 Favorites, 0 Comments

Sump Pump Diagnostics, Alerts, and Monitoring

sumpMaster.PNG

I had installed a sump basin water alert system using a RPi. Now, I wanted something that would be more proactive and alert me when the sump pump performance was starting to go off normal instead of waiting for the water level threshold to be tripped. The cost of cleaning up the damage from a flooded basement can be enormous. Typically costs are in the range of $3,000 to $10,000 and sometimes much higher with larger finished basements. Insurance companies will often cover the cost if the flooding is determined to be accidental but there is still the time and effort of getting bids from contractors and overseeing the work.

Basement sump pump systems have a lot of components that can fail including primary pump, float switches, one-way check valves, frozen discharge pipes, etc. This project uses a low-cost energy monitor to detect abnormal operation of the sump pump motor even before a high level water alarm can be triggered. The module uses a split core current transformer to measure the current flowing in the electric wire to the sump pump motor. Said in another way, the transformer clips around the wire without removing any insulation and indirectly senses the current flow. This makes installation much simpler.

I found that under normal operation the motor power consumption is very constant. Frequency of sump operation was highly variable being governed by the amount of water flowing into the basin, but actually sump operation on time was always very consistent; being the time it takes for the water level in the basin to be pumped out. If either power or runtime varies, something is abnormal.

Conditions that could cause abnormal power indications that sumpMaster would detect include:

  • Frozen discharge/drain pipe (detection of abnormal power)
  • Motor / impeller damage (detection of abnormal power)
  • Motor starter capacitor (detection of abnormal run time)
  • Water level switch stuck on (detection of abnormal run time)
  • Check valve malfunction (detection of abnormal run time)

There are two algorithms to generate alerts. One is statistical based and self learns. The other algorithm option is based on entering the horsepower size of the pump motor. Alerts can be sent to your email or as an SMS to your phone.

SumpMaster tracks energy used from the sump pump and sends status reports:

Period stats:

  • Number of cycles and power consumed
  • Min, max, and total run times

Per on cycle:

  • Run time and standard deviation
  • Average power and standard deviation

Data Logging (time series of records) can be to any of the following:

  • Comma Separated Variable (CSV)
  • MQTT (publish/subscribe message queue)
  • influxDB
  • SQL (multiple variations to be added)
  • Future options: IFTT, PubNub, Twilio, Cellular, APRS

Supplies

Checkout the GitHub site referenced below for further information on these parts.

PZEM Module (about $20 USD)

  • For Alternating Current (AC) pump motors: PZEM-016
  • For Direct Current (DC) pump motors: PZEM-017

Raspberry Pi system (if you don’t already own one)

  • Any one of the following: RPI-Zero RPI 3B+ RPI 4B

Wiring

PZEM.PNG

The PZEM-016 includes instructions. Basically the split core current transformer (CT) is fastened around the neutral wire allowing indirect current sensing. The PZEM module will need to be plugged in to a power source to power the module (80 – 260 VAC range) . The PZEM communicates over a single low-voltage twisted pair to a included USB-dongle using RS-485 so it can run up to 300 meters or roughly 1,000 feet. The USB dongle is plugged into a USB port on the RPi4 or RPi3, or via a USB cable on the RPI zero. If you are at all unsure, consult an electrician for local electrical and building codes.

Setup the Raspberry Pi Operating System

There are multiple excellent tutorials on installing the RPi operating system on an SD-card that you may want to consult that go into the specific steps. Here is the link to the Raspberry Pi Operating System image: https://www.raspberrypi.org/software/operating-systems/

Before continuing make sure your operating system has been updated with the latest updates.

sudo apt-get update

sudo apt-get full-upgrade

sudo reboot now

Install the required Python libraries that sumpMaster uses:

sudo pip3 install pymodbus

sudo pip3 install matplotlib

Download the Open Source Code

To get a copy of the source files type in the following git command assuming you have already installed git:

git clone https://github.com/BrucesHobbies/sumpMaster

Configure SumpMaster Software (optional)

To add additional PZEM modules, add a name to the chanNames list in sumpMaster.py.

chanNames = ["SumpPump"]
# chanNames = ["SumpPump", "Pump2", “Pump3”, “Pump4”] # Example with 4 pumps
chanPorts = ["/dev/ttyUSB0", "/dev/ttyUSB1","/dev/ttyUSB2", "/dev/ttyUSB3"]   # One entry per chanName[]
chanAddrs = [0x01, 0x01, 0x01, 0x01]                       # One entry per chanName[]
chanOnThresholds = [5, 5, 5, 5]                     # Watts, with one entry per chanName[]

The source code is 100% Python. To disable or enable status messages and alerts modify these lines:

statusMsgEnabled = 1                              # non zero enables sending of email / SMS text messages
statusMsgHHMM    = [12, 0]                        # Status message time to send [hh, mm]

alertMsgEnabled  = 0                              # non zero enables sending of email / SMS text messages
runTimeAlert = [30*60] * len(chanNames)           # Run time to trigger email / SMS text - seconds
minIntervalBtwEmails = [2*3600] * len(chanNames)  # Wait this long before sending another email - seconds

Run the Program

From the command line:

python3 sumpMaster.py

On first time startup the sumpMaster will ask if you want to enter an email address or phone number for alerts and status messages. You can skip this step and come back to this step later. The entries are saved in the file emailCfg.json, so you would need to delete this file to get the program to ask for the information again.

To update the sump pump monitoring algorithm, see the comments in algsump.py.

To plot the logged data use the plotSumpMaster.py which provides example plots. Customize to suit your interests.

Enjoy!

Auto Start at Reboot (Optional)

Type the following command:

sudo crontab –e

Select the type of editor you are familiar with. I used nano. Add the following line at the end of the file and then press ctrl+O to write the file and ctrl+X to exit the nano editor.

@reboot sleep 60 && cd sumpMaster && python3 sumpMaster.py