Living on an acreage, I have a well and septic system. If a hose or pipe bursts, it can be undetected for some time and cause major damage.
This project senses current of the well pump and septic pump motors. It will send you a warning text if they run too long. Also, I have a habit of forgetting the bath water running. The project will give a buzzer warning if the well pump runs longer than 6 minutes(the length of time for normal bath level) The texts will be sent when the pump time settings are exceeded. (Don't laugh...you will be old some day too!...lol) Each time the pumps run, their on-time is recorded and displayed once they stop. (non-volatile) You must also uncomment the lines of code specified for the first run only, to create a memory file.
Code: [Local Link Removed for Guests]
'Zim's Annex Pump monitor v1
onHtmlReload create_page
onhtmlchange update
EMAIL.SETUP "smtp.gmail.com", 465, "zim@gmail.com", "zim1234" 'replace with your login / password
D1 = 5:D2 = 4:D5 = 14:D6 = 12
PIN.MODE D1, INPUT 'Water pump
PIN.MODE D2, INPUT 'Septic pump
PIN.MODE D5, OUTPUT 'buzzer
PIN.MODE D6, OUTPUT 'led
PIN(D5)= 1 'buzzer
PIN(D6)= 0 'led
'file.save "/SPhistory.txt", str$(1) 'for first run
'file.save "/WPhistory.txt", str$(1) ' "
Wpset = 10 'adjust when to alarm XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Spset = 8 'adjust when to alarm XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
tubset = 6
Wlook$ = file.read$("/WPhistory.txt")
Slook$ = file.read$("/SPhistory.txt")
WpumpC = 0 'waterpump counter
SpumpC = 0
WpumpD = 0 'waterpump displayed
SpumpD = 0
WPtrg = 0 'waterpump ALARM TRIGGERS
SPtrg = 0
tubtrig = 1
WpumpD$ = "0" 'used for conversion to string to get one decimal place in display
SpumpD$ = "0" 'used for conversion to string to get one decimal place in display
WPinmem$ = ""
SPinmem$ = ""
stat$ = "Last Run Times" 'STAT WINDOW
ad$ = "zim@gmail.com":nu$ = "72451141113@msg.telus.com":ti$ = "Pumps"
txtbW$ = "text-align:center;display:block;width:75px;height:42px;font-size:30;font-weight:bold"
txtbS$ = "text-align:center;display:block;width:75px;height:42px;font-size:30;font-weight:bold"
txtbstat$ = "text-align:center;display:block;width:160px;height:26px;font-size:15;font-weight:bold"
gosub create_page
timer0 1000, update
wait
create_page:
cls
A$ = ""
A$ = A$ + |<!DOCTYPE html><html><body><style>|
A$ = A$ + |body {background-color: black;}|
A$ = A$ + |p {font-size:24px;}|
A$ = A$ + |</style>|
A$ = A$ + |</style><center>|
A$ = A$ + |<center>|
A$ = A$ + |<p><font color = 'white', font size = '6'>Pump Monitor</font></p>|
A$ = A$ + |</center>|
A$ = A$ + |<table align='center' width='300' height='100' bgcolor='lightgreen' border='1' cellpadding='8'>|
A$ = A$ + |<th>|
A$ = A$ + |<p>Well Pump<br>Running<br>Minutes</p></th></center>|
A$ = A$ + |<th><center>|
A$ = A$ + textbox$(WpumpD, "txt1")
A$ = A$ + |</th></center>|
A$ = A$ + cssid$("txt1", txtbW$)
A$ = A$ + |</table>|
HTML A$
A$ = ""
A$ = A$ + |<table align='center' width='300' height='100' bgcolor='lightgreen' border='1' cellpadding='8'>"|
A$ = A$ + |<center><th>|
A$ = A$ + |<p>Septic Pump<br>Running<br>Minutes</p>|
A$ = A$ + |</th></center>|
A$ = A$ + |<th><center>|
A$ = A$ + textbox$(SpumpD, "txt2")
A$ = A$ + |</th></center>|
A$ = A$ + cssid$("txt2", txtbS$)
A$ = A$ + |</table>|
A$ = A$ + |<table align='center' width='300' bgcolor='lightblue' border='1' cellpadding='8'>|
A$ = A$ + |<td><center>|
A$ = A$ + |<b><big>Pump Status</big></b>|
A$ = A$ + |</center><center>|
A$ = A$ + textbox$(stat$, "txt4")
A$ = A$ + cssid$("txt4", txtbstat$)
A$ = A$ + |</center></td></table>|
A$ = A$ + |<br><center>|
A$ = A$ + button$("<b><big>Turn OFF</big><b/>", offf)
A$ = A$ + | |
A$ = A$ + button$("<b><big>Reset</big><b/>", reset)
A$ = A$ + |</table>|
HTML A$
A$ = ""
if WpumpD >= Wpset then html cssid$("txt1", "box-shadow: 12px 0px red;") 'else html cssid$("txt1", "box-shadow: 12px 0px lightgreen;")
if SpumpD >= Spset then html cssid$("txt2", "box-shadow: 12px 0px red;") 'else html cssid$("txt2", "box-shadow: 12px 0px lightgreen;")
if WPtrg > 0 then stat$ = "Well Pump Alert" else stat$ = "Last Run Times"
if SPtrg > 0 then stat$ = "Septic Pump Alert" else stat$ = "Last Run Times"
autorefresh 1000
return
update:
PIN(D6)= 0
if (WpumpD >= Wpset)and(PIN(D1)= 1) then PIN(D5)= 0 else PIN(D5)= 1
if (SpumpD >= Spset)and(PIN(D2)= 1) then PIN(D5)= 0 else PIN(D5)= 1
if PIN(D1)= 1 then
WpumpC = WpumpC + 1
WpumpD$ = STR$(WpumpC/60, "%2.1f")
WPinmem$ = WpumpD$
WpumpD = val(WpumpD$)
endif
if (PIN(D1)= 0) then Wlook$ = file.read$("/WPhistory.txt")
if (PIN(D1)= 0)and(val(WPinmem$) <> val(Wlook$))and(val(WPinmem$) <> 0) then file.save "/WPhistory.txt", WPinmem$ 'only writes file when different
if (PIN(D1)= 0) then
WpumpC = 0
WpumpD = val(Wlook$)
endif
if PIN(D2)= 1 then
SpumpC = SpumpC + 1
SpumpD$ = STR$(SpumpC/60, "%2.1f")
SPinmem$ = SpumpD$
SpumpD = val(SpumpD$)
endif
if (PIN(D2)= 0) then Slook$ = file.read$("/SPhistory.txt")
if (PIN(D2)= 0)and(val(SPinmem$) <> val(Slook$))and(val(SPinmem$) <> 0) then file.save "/SPhistory.txt", SPinmem$ 'only writes file when different
if (PIN(D2)= 0) then
SpumpC = 0
SpumpD = val(Slook$)
endif
if (PIN(D1)= 1)and(WpumpD < Wpset) then stat$ = "Water Pump is ON"
if (PIN(D2)= 1)and(SpumpD < Spset) then stat$ = "Septic Pump is ON"
if (PIN(D1)= 0)and(PIN(D2)= 0)and(WpumpD < Wpset)and(SpumpD < Spset) then let stat$ = "Last Run Times"
PIN(D6)= 1
'if WpumpD <> 6 then tubtrig = 0
'
if WpumpD > Wpset gosub alert_WP
if SpumpD > Spset gosub alert_SP
refresh
if WpumpD = 6 then
PIN(D5)= 0 'buzzer
pause 100
PIN(D5)= 1 'buzzer
pause 1000
PIN(D5)= 0 'buzzer
pause 100
PIN(D5)= 1 'buzzer
endif
return
alert_WP:
WPtrg = WPtrg + 1
if WPtrg > 0 then stat$ = "Well Pump Alert" else stat$ = "Last Run Times"
if WPtrg >= 3600 then WPtrg = 0 'will email every hour
if WPtrg <> 1 return
html cssid$("txt1", "box-shadow: 12px 0px red;")
print EMAIL (ad$, nu$, ti$, "Well Pump Running Long")
pause 100
'wlog "Well pump running long"
return
alert_SP:
SPtrg = SPtrg + 1
if SPtrg > 0 then stat$ = "Septic Pump Alert" else stat$ = "Last Run Times"
if SPtrg >= 3600 then SPtrg = 0 'will email every hour
if SPtrg <> 1 return
html cssid$("txt2", "box-shadow: 12px 0px red;")
print EMAIL (ad$, nu$, ti$, "Septic Pump Running Long")
pause 100
'wlog "Septic Pump Running Long"
return
reset:
SpumpD = 0:WpumpD = 0:WpumpC = 0:SpumpC = 0:WPtrg = 0:SPtrg = 0:WPinmem$ = "":SPinmem$ = ""
PIN(D5)= 1
file.save "/SPhistory.txt", str$(0)
file.save "/WPhistory.txt", str$(0)
goto create_page
return
tubalert:
if tubtrip = 1 return
PIN(D5)= 0 'buzzer
pause 1000
PIN(D5)= 1 'buzzer
pause 1000
PIN(D5)= 0 'buzzer
pause 1000
PIN(D5)= 1 'buzzer
pause 1000
PIN(D5)= 0 'buzzer
pause 1000
PIN(D5)= 1 'buzzer
tubtrip = 1
return
offf:
PIN(D5)= 1
timer0 0
cls
butt$ = "background-color:lightblue;text-align:center;display:block;width:180px;height:80px;font-size:40;font-weight:bold;box-shadow: 3px 3px black;border-radius:5px;line-height:1"
A$ = A$ + |<!DOCTYPE html><html><body><style>|
A$ = A$ + |body {background-color: black;}|
A$ = A$ + |p {font-size:36px;}|
A$ = A$ + |</style>|
A$ = A$ + |<br><center>|
A$ = A$ + BUTTON$("Restart", turnon, "but1")
A$ = A$ + cssid$("but1", butt$)
A$ = A$ + |</center>|
A$ = A$ + |</body>|
A$ = A$ + |</html>|
HTML A$
A$ = ""
autorefresh 1000
PIN(D2)= 1
onHtmlReload offf
return
turnon:
PIN(D2)= 0
cls
reboot