MagPi Questions

Please tell us about yourself and your technical background as well as what got you interested in Raspberry Pi.  

I have a degree in industrial education, but it all started long before I graduated. My dad was a design engineer and brought home special projects. Super duper calculators. Electronics projects.

I’ve only taken a few formal programming classes and am mostly self-taught. When Raspberry Pi first came out, I was working for LinkedIn and decided to create a class on how to use and program this single-board computer.

What were the project aims? Please describe its capabilities and Raspberry Pi’s role (and any limitations you’re trying to overcome or extra functionality you intend to add). 

My urban garden needs irrigation during the summer months. The simple solution is to use commercially available irrigation timers; they turn on, then turn off. Simple enough. They cost about thirty dollars.

If you forget to bring them in during the winter, they freeze and break. After a few years, the plastic valves wear out and they jam closed (bad for plants) or jam open (bad for water bills). They don’t adjust to rain or hot weather.

You can buy more robust timers. Some of them have Internet connectivity and look up the weather forecast. They cost about $100. If you leave them outside they freeze and break.

Or… You can use your knowledge of raspberry pi and the assortment of parts in the electronics box to build your own.

Why did you choose to use a Raspberry Pi for this project and which Raspberry Pi are you using? 

I chose a Raspberry Pi for three reasons:

  • I need internet connectivity if I am going to look up weather reports.
  • My preferred language is R, which I can run from a linux operating system, but not from micropython or C
  • I have several Raspberry Pi’s gathering dust in my office. I should use them.

I am using a Raspberry Pi Zero WH. The wireless makes it easy to connect to the internet and the headers provide a convenient way to connect relays and buttons.

Please tell us about any other Raspberry Pi projects you’ve designed or ones that inspired this one. 

I’ve taught the LinkedIn Learning Raspberry Pi Essentials course and designed several projects for instruction and to demonstrate various sensors, servos, and switches. I’ve also embedded a raspberry pi in a Big Mouth Billy Bass.

Were there any particular challenges/advantages in designing it? 

This project requires a mix of a lot of parts:

  • The Raspberry Pi controller
  • Designing the logic to convert the desired amount of water balanced against rainfall (measured in inches) into seconds to hold the valves open to deliver irrigation water (measured in gallons per hour)
  • Programming the logic in R
  • Controlling relays to control the voltage required by the irrigation valves
  • Plumbing the flow of water from house lines through irrigation valves and out to the drip irrigation system

Is the design based on an existing project or did you have to design and create some or all the parts yourself? 

Entirely my own making. No plans needed, but there is a bit of experimentation required. Prior knowledge of plumbing and electronics is helpful.

How/where did you source the parts and software for it? 

All the parts are available at your local hardware store-or at adafruit.

Please detail the experience of setting up the project using Raspberry Pi. We will need at least three photos to illustrate the setup/assembly process please. 

I’ve documented the existing tool at https://github.com/mnr/sprinklR/wiki . This includes lots of photos

There is a dashboard showing performance at https://niemannross.com/sprinklR

This photo shows the development board. It’s just a piece of scrap wood with components temporarily screwed in place. At the top is the power for Raspberry Pi and irrigation valves. In the middle is the Raspberry Pi Zero, below that is the two servos used to control the irrigation voltage, and below that is the irrigation valves.

A jumble of electronics on a wood board

There isn’t any water connected to the system at this point – I’m only trying to test the electronics and develop and test the code. In particular, I’m trying to see if the software & hardware are providing realistic results. I don’t want to give it access to my water bill until I’ve reality checked its performance.

Here is an overall picture of the three parts. Left: Irrigation valves and plumbing, Center: Raspberry Pi and relays, Right: power.

Notice I’ve moved the project to a larger and more formal board. This shape was more suited to the layout of the parts. I wanted the plumbing to be physically below power and the Raspberry Pi in case there was a leak.

This is a closeup of the raspberry pi. I’ve housed this in a mason craft food preservation container. Costs about $3 and is waterproof – hopefully something I don’t need.

The base of the container is attached to the board chassis and has a hole to allow feeding wires through a notch in the base and up to the RPi. Access is by pulling off the jar – it’s held on by a gasket. Because the RPi Zero uses so little energy, cooling is not a problem.

Did you have to go through several iterations in order to get it just right and what did you have to tweak, if so? 

I proceed slowly, testing prototypes of each step. I did the coding on the RPi before it was hooked up to anything. I ran it with the relays for days without any valves connected. I tested the plumbing in a sink before I attached it to the board. So yes – I interate constantly.

What software/code does it run on and has the setup changed as you have refined it over time?

I run this on linux – my programming language of choice is R. The code constantly changes – thank god for git and github. I do a lot of development on a Macintosh, then push to github. I ssh into the Raspberry Pi and pull from github to update the running code. This gives me a slight buffer from the online system, and github provides me with a backup should the memory chip in the RPi fail.

Is the software available on GitHub or another open-source site? Any links you can share here would be great! 

  • Github Repository: https://github.com/mnr/sprinklR
  • Wiki documentation: http://niemannross.com/link/irrigation
  • Support for R access to Raspberry Pi GPIO: https://github.com/mnr/rpigpior
  • R for the Raspberry Pi family of computers: https://r4pi.org/

How much did it cost to build and how long did it take? Are there any significant running costs? Were there any particular challenges or unexpected hurdles?

  • Raspberry Pi Zero WH: $10?
  • Relays: $7 x 2 = $14
  • Irrigation Valves: $15 apiece
  • Random PVC: $25?
  • Power box, transformer, assorted parts: $25

How has using Raspberry Pi been beneficial to the project?

I wouldn’t have attempted this unless I was familiar with Raspberry Pi

How else do you think the ideas in the project could be used (if at all)? 

What advice would you give to someone who wanted to embark on a similar project? 

Think in small steps. Know where you are heading, but build the easy stuff first, then build up in complexity.

What hardware will readers need if they want to make their own?

Do you plan to do more with this project/with Raspberry Pi?

Finally, please tell us five fun/interesting facts about you or the project. 

  1. My next project is automating a chicken coop. Each chicken will get an RFID tag
  2. After that, I hope to build a homebrew GPS system for sea kayak navigation
  3. I write Science Fiction. My latest novel is “Stupid Machine” – a murder mystery solved by a refrigerator
  4. I have only taken one formal computer programming class in my life
  5. I have a degree in Industrial Education