So you've got yourself an Arduino board to monitor your evacuation pump and loaded the pump monitor code on it? Congrats, that's half the equation! Now you need some backend code to monitor the monitor.
flush.php
This is the endpoint that the pump monitor's HTTP request will hit. It's responsible for parsing out the query params, determining the type of request (startup, pumping or healthcheck) and inserting a row into a database table.shitshow.php
This is an endpoint used to display recent requests in a graph format (see below for more info).wipecheck.php
This is an optional script that should be cron'd. It will monitor recent usage and send a text message via Textbelt if any thresholds have been met.
- Get the pump monitor setup
- Setup a webserver with a relational database
- Create a table for storing pump events (see below)
- Clone this repo in a web directory
- Create an .env file and lock it down (see below)
CREATE TABLE `pump_events` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`x_value` double(4,2) NOT NULL,
`y_value` double(4,2) NOT NULL,
`z_value` double(4,2) NOT NULL,
`type` int(11) NOT NULL,
`timestamp` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `timestamp` (`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
The .env file contains all the personal data that needs to be kept out of source control. Make sure that it's readable by your webserver's user, but otherwise locked down (eg. chown <youruser>:<webuser> .env && chmod 640 .env
).
IMPORTANT: Make sure this file isn't leaked to the world by your webserver!
<mysql database>
<mysql username>
<mysql password>
<pump/health call auth code>
<textbelt auth token>
<SMS (comma delimited) recipient numbers>
The shitshow.php endpoint uses Chart.js to display recent events and accomodates a few optional GET parameters:
days
(Default: 7) Changes the number of days rendered in the chartdeduced
(Default: true) Toggles whether washing machine events are interpretted from the given pump events and displays them as a separate dataset. Note: This is admitedly very specific to my setup and should probably be 1) configurable and 2) not on by default, but hey, I'm the only one using this at the moment.