A DIY web driven scheduler system for the Raspberry Pi written in Python using lighttpd and pigpio. This is typically used to support a irrigation system with multiple sprinkler valves, but you could also use it to control other devices.
(If you are looking for a more turnkey and feature rich solution for your RPi, I highly recommend OpenSprinkler Pi instead.)
- Raspberry Pi (or other dev board capable of running Python and Lighttpd)
- WiFi dongle (if not using RPi v3)
- Power Supply for RPi
- 24V AC Sprinkler Power Supply
- Sprinkler Valves
- 5V Relay Board
- Lighttpd must be installed
- Pigpio must be installed (Installed by default on Raspbian)
- RPi must be configured to connect to your network
auth.debug = 2
auth.backend = "plain"
auth.backend.plain.userfile = "/etc/.lighttpdpassword"
auth.require = ( "/cgi-bin/" =>
(
"method" => "basic",
"realm" => "Password protected area",
"require" => "user=admin"
)
)
$HTTP["url"] =~ "^/" {
cgi.assign = (".py" => "/usr/bin/python")
}
Change the username from "admin" to whatever you want.
admin:password
Change the password to whatever you want.
Run the following command to enable the cgi mod.
lighty-enable-mod cgi
Create a file in your www root directory (i.e. /var/www/html) called index.html that will redirect traffic to the index.py script.
<html>
<head>
<meta http-equiv="refresh" content="0; url=/cgi-bin/index.py" />
</head>
</html>
sudo service lighttpd restart
sudo chmod +x /path-to-your-cgi-bin-directory/*
sudo chown www-data:www-data /path-to-your-cgi-bin-directory/*
sudo nano /etc/rc.local
Add ...
pigpiod &
/<path-to-your-cgi-bin-directory>/sprinkler.py &
... before the "exit" statement. Reboot your Raspberry Pi.
Reboot your RPi. Open a web browser and type in the IP address of your RPi. You should see the index.py page.
The first time you connect to the web page a new config file should be created. Open the sprinkler.config file and change the values in [Station GPIOs] to match the GPIO pins you connected to your relay board.
Add the "www-data" user to the /etc/sudoers file by using visudo. NOTE: This weakens the security of your system in that a knowledgeable person might be able to reboot or shutdown your RPi. You have been warned.
sudo visudo
Add these lines to the bottom of the file.
www-data ALL=/sbin/shutdown
www-data ALL=NOPASSWD:/sbin/shutdown
Need to make it look prettier.