Introduction: Sump Pump Water Level: the Software
This is the second part of my sumppump water level sensor.
You can find the first part on how to built a water level sensor, here:
https://www.instructables.com/id/Sump-pump-water-level-The-hardware/
Needed:
-Raspberry Pi with
Apache
PHP
Sendmail or postfix if you want a email warning.
What the software will do:
The command part
This part is invisible to the user and is (and should be ) independent of the webpage.
Using cron, it will read the water level every minute and save the information to a file. If the water level reaches a certain level, an email will be sent. This is the most important part.
The Web page
In this part, the web page reads the information from the file written by the cron job and displays an image of your pit.
You can find the first part on how to built a water level sensor, here:
https://www.instructables.com/id/Sump-pump-water-level-The-hardware/
Needed:
-Raspberry Pi with
Apache
PHP
Sendmail or postfix if you want a email warning.
What the software will do:
The command part
This part is invisible to the user and is (and should be ) independent of the webpage.
Using cron, it will read the water level every minute and save the information to a file. If the water level reaches a certain level, an email will be sent. This is the most important part.
The Web page
In this part, the web page reads the information from the file written by the cron job and displays an image of your pit.
Step 1: Download and Copy the Software
Download the zip file and uncompress it to the webfolder of your Raspberry. I recommend creating a subfolder at the root of your www folder. Typically, the folder path is /var/www/sumppump.
Attachments
Step 2: Ajust the Preferences
Open the file "chklevel.php" with a text editor and change the line 3 to reflect the path to the folder where you copy all the files.
chdir('/var/www/sumppump/');
Save and close the file.
--------------------
Open the file "preference.php". All the preferences are explained in the comments.
The $levelamber and $levelred variables change the color of the led on the webpage and sends an email to the $to variable.
Be careful: If you set the $preferunit to cm, be sure to set all other measements to cm. The same thing applies in reverse cms to inches."
Refer to this images for the definition of some variables
chdir('/var/www/sumppump/');
Save and close the file.
--------------------
Open the file "preference.php". All the preferences are explained in the comments.
The $levelamber and $levelred variables change the color of the led on the webpage and sends an email to the $to variable.
Be careful: If you set the $preferunit to cm, be sure to set all other measements to cm. The same thing applies in reverse cms to inches."
Refer to this images for the definition of some variables
Step 3: Schedule the Cron Task
Connect to your Raspberry as root and type this command to edit the scheduled task
crontab -e
Add this line to your crontab file:
* * * * * php /var/www/sumppump/chklevel.php
This will instruct to run the php script at every minutes of every hour of every...
Save the file with ctrl-o and ctrl-x to close the file.
crontab -e
Add this line to your crontab file:
* * * * * php /var/www/sumppump/chklevel.php
This will instruct to run the php script at every minutes of every hour of every...
Save the file with ctrl-o and ctrl-x to close the file.
Step 4:
Voila. If you type in http://myserver/sumppump in your browser , you should be able to see your sumppump.
Note that it's not really a dynamic image of your pit. In fact, what compose the image is a table of three row containing a top image with the sensor, a middle one with the grey background, and a third one with the blue background. The height of the row is determine by the level of water.
*** This code was test in my system only. If you encounter any bug, please write a comment at the bootom of the page.
Note that it's not really a dynamic image of your pit. In fact, what compose the image is a table of three row containing a top image with the sensor, a middle one with the grey background, and a third one with the blue background. The height of the row is determine by the level of water.
*** This code was test in my system only. If you encounter any bug, please write a comment at the bootom of the page.