Pothibo

Control your sprinklers on your Raspberry Pi

The Raspberry Pi gave me a new opportunity for my irrigation system at home. A few years back (~ 10 years ago), I worked for a landscaping company and I learned the importance of having an irrigation system to help your grass grow dense and your plants to be healthy. You don't want to waste thousands of dollars on plants just to see them dying over the next few years.

So last year I bought a system that was recommended by an "expert", cost me 350$. Threw it out last summer because it was total crap. Then, instead of buying another piece of shit for 200$, I thought that the Pi would be a perfect fit. Here's what I wanted it to do:

  • Flexible numbers of zones (17 zones builtin, can add another 4 if needed);
  • Very simple scheduling system;
  • Persist data (battery are stupid, hard drives exist for a reason);
  • Web based access;
  • Manual control if I need to open valves;
  • Name my valves so they are easy to work with;
  • Customizable!

With this in mind, I started working on my project codenamed irrigation  (original, right?). Since the Pi doesn't have a whole lot of horsepower, I thought that this was a very good reason to learn Go and build the whole web server with it, backed by sqlite for storing data.

Installation

This project has been tested on Arch Linux only, but I believe it should work fine on raspbian. Let's start by installing the dependencies we need.

# pacman -Sy bzr sqlite3 go git pkg-config gcc

Now, as a user (not root), compile & install the project. All the dependencies will be fullfil by go automatically.

$ export GOPATH=~/go $ go get github.com/pothibo/irrigation

Assets & Configuration file

The project has some assets (html, css, js) and a config file that is required in order to work properly. Since we are serving web pages, it would make sense to link those file to /srv/http/irrigation.

$ sudo mkdir /srv/http/irrigation $ sudo chown your_user /srv/http/irrigation $ sudo chgrp http /srv/http/irrigation $ ln -s $GOPATH/src/github.com/pothibo/irrigation/assets/ /srv/http/irrigation/assets $ ln -s $GOPATH/src/github.com/pothibo/irrigation/config.yml /srv/http/irrigation/config.yml

You can modify config.yml to your liking, but the default value should be fine. The valves number are available here. An idea would be to start playing with the current settings and change them if needs be.

Initialization

Almost done, before you can run the server, you need to activate the relay (They aren't activated by default). The activation is based on config.yml valves. Only those will be enabled. You will also need to have superuser privilege to enable the relays.

$ sudo $GOPATH/bin/irrigation -activate

Now initialize the database;

$ $GOPATH/bin/irrigation -initdb

And start the server!

$ $GOPATH/bin/irrigation -server

You should now be able to access your irrigation controller via raspberry_pi_IP:7777

You can read more about the hardware I used for my setup, if you liked this post, you may want to follow me.

Get more ideas like this to your inbox

You will never receive spam, ever.