Giter Site home page Giter Site logo

black3806 / pi-sprinkler-timer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aaronnewcomb/pi-sprinkler-timer

0.0 1.0 0.0 42 KB

A web driven scheduler system for the Raspberry Pi written in Python using lighttpd and pigpio.

License: MIT License

Python 99.59% HTML 0.41%

pi-sprinkler-timer's Introduction

pi-sprinkler-timer

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.)

Parts:

  • 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

Pre-requisites:

  • Lighttpd must be installed
  • Pigpio must be installed (Installed by default on Raspbian)
  • RPi must be configured to connect to your network

Installation:

Configure Lighttpd to run python scripts with password protection.

1. Add the following to your /etc/lighttpd/lighttpd.conf configuration file:

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.

2. Create a file called /etc/.lighttpdpassword with one line in it:

admin:password

Change the password to whatever you want.

3. Enable cgi for Lighttpd

Run the following command to enable the cgi mod.

lighty-enable-mod cgi

4. (optional) Add redirection to index.py

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>

5. Restart Lighttpd.

sudo service lighttpd restart

Copy scripts

1. Download this github repository and copy index.html to your web root directory.

2. Copy all the other ".py" scripts to your cgi-bin directory.

3. Give files in your cgi-bin location execute privilages and the correct ownership.

sudo chmod +x /path-to-your-cgi-bin-directory/*
sudo chown www-data:www-data /path-to-your-cgi-bin-directory/*

4. Add pigpiod and the scheduler to rc.local so they start when the Pi boots up.

sudo nano /etc/rc.local

Add ...

pigpiod &
/<path-to-your-cgi-bin-directory>/sprinkler.py &

... before the "exit" statement. Reboot your Raspberry Pi.

Give it a try

Reboot your RPi. Open a web browser and type in the IP address of your RPi. You should see the index.py page. pi-sprinker-timer main web page

Add your GPIO pins

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.

Enable reboot and shutdown from the web page

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

Issues ๐Ÿ’ฉ

Need to make it look prettier.

pi-sprinkler-timer's People

Contributors

aaronnewcomb avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.