Rasberry PI 3 powered septic tank dosing chamber level monitor with dosing pump control and Web Server.

Python Scripts
Name/LinkPurpose This is the primary python script that runs all the time, takes distance readings using sensor, logs readings to SQL, turns pump on and off, controls indicator light. This python script runs on a cron schedule every 30 minutes it calls the sp_CheckLogs SQL stored procedure which checks the SQL logs to be sure it's working correctly. If it finds an error condition it sends a notification email. This python script is a utility script that can be ran manually to turn the pump on for 10 minutes then turn it off and log the pump actions. If the distance sensor is broke I will sometimes setup a Cron task to run this once a day to ensure the tank does not overflow.

sp_CheckLogs This Procedure checks the SQL tables to be sure everythinhg looks right, Checks time since last reading, Checks to be sure Pump has not been on too long, Checks to be sure tank reading levels are changing, checks readings to be sure they are realistic.
sp_GetStats This Procedure gathers the readings from the database for the Home page section. Things like Last reading, Current Distance etc.
sp_GetTankChartData This Procedure gathers the data from database that is used for the History Chart
tanklog Table This table stores the distance readings that are gathered
pumplog Table This table stores when the pump was turned on and off

PHP Pages
default.php This is the Home page
chart.php This is the Level history Chart page