Use a Raspberry Pi to control your sprinkler system.
- Raspberry Pi [3,4,5]
- Raspberry Pi OS Lite (64 bit) - No desktop environment
- Power Relay Hat
- 3.5" Display Hat (Optional)
- Fuse Holder Inline
- BOJACK 5x20 mm Fuse Holder Inline
- Check your sprinkle system to see what the max draw is, mine recommended 0.75 Amps
- Manual On/Off Switch (Override and disable the system)
- Wire
Wiring
- Clean install of Raspberry Pi OS Lite (64 bit) - No desktop environment
- Python 3
sudo apt install python3
- Docker & Docker Compose
- git
sudo apt install git
- Clone repo
git clone https://github.com/tuxthepenguin84/raspberry-sprinkles.git
docker build -f Dockerfile.api . -t sprinkles/sprinklesapi:latest --secret id=git_credentials,src=/root/.netrc --build-arg CACHEBUST=$(date +%s)
docker build -f Dockerfile.scheduler . -t sprinkles/scheduler:latest --secret id=git_credentials,src=/root/.netrc --build-arg CACHEBUST=$(date +%s)
docker compose up -d
If you want the console output similar to the main picture, append the following to .bashrc
while :
do
sudo /home/pi/git/raspberry-sprinkles/stats.sh
sleep 10
done
- rsapi.py - Flask API that runs the backend of Raspberry-Sprinkles (tcp/5000)
- rsclient.py - Client library that makes it easy to interact with the API
- rsscheduler.py - Runs automated schedules
- schedule.json - (Not shown) this is a JSON file that contains your sprinklers and schedules
- rsschedule_builder.py - Builds your schedule.json based on sprinklers and specified schedules
- test_rsapi.py - Unit testing for Raspberry-Sprinkles
- run_unit_testing.sh - Used to call test_rsapi.py for unit testing
- requirements.txt - Python requirements for Raspberry-Sprinkles
- params.json - Used for issuing rain delays automatically based on weather and location information
Raspberry-Sprinkles can build any type of schedule you require for your sprinkler system and supports different types of schedules depending on the current season.
- Edit schedule_builder.py and modify "Add Sprinkler" section based on how many sprinklers you have. You will need to add a Name and Gallons Per Min, if you don't know how many gallons per min your sprinklers are fill in any number.
- Next edit the season section and begin adding entries for each sprinkler run. Days are as follows: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']. If you want the sprinkler to run every day use "Everyday". If you want a sprinkler to run the same schedule no matter what season add it to the ALL SEASONS section.
- When you are done run the following to build a schedule.json:
/usr/bin/python3 /home/pi/git/raspberry-sprinkles/rsschedule_builder.py
- The rsapi service will automatically pickup the schedule.json and run at the requested times.
- There is a known bug where if one sprinkler is stopping in the same minute as another sprinkler is starting it will not start the sprinkler. As a result do not have any sprinklers end the same minute another sprinkler is starting.
Run schedule ID 1,5,9,13,17
curl -s -X PUT http://127.0.0.1:5000/runschedule -d scheduleids=1,5,9,13,17
Run sprinkler 1 for 10 minutes
curl -s -X PUT http://127.0.0.1:5000/runadhoc/1 -d runtime=10
curl -s -X DELETE http://127.0.0.1:5000/stoprunning
Adds a rain delay for 24 hours (Increments by 24 hours on each run)
curl -s -X PATCH http://127.0.0.1:5000/raindelay
View current rain delay
curl -s -X GET http://127.0.0.1:5000/raindelay
Remove rain delay
curl -s -X DELETE http://127.0.0.1:5000/raindelay
curl -s -X DELETE http://127.0.0.1:5000/resetall
While there is no official front end for Raspberry-Sprinkles, a basic UI can be constructed from another project call Olivetin. Olivetin supports mobile browsers and makes a safe and simple web interface which can run predefined shell commands. See olivetin/raspberry-sprinkles-config.yaml
for a sample configuration you can use and adapt into your own Olivetin instance.
There is no https support. However, I recommend building an Nginx Reverse Proxy.
- ✅ | Add API Functionality
- ✅ | Support multiple schedules based on season
- ✅ | Weather integration for automated schedule adjustment - https://open-meteo.com/
- ⬜️ | Add API Key Auth: https://blog.teclado.com/api-key-authentication-with-flask/