The next project I’m working on is the OpenSprinkler timer. OpenSprinkler is an open source internet-controlled and internet-connected irrigation timer (http://opensprinkler.com). Initial version of the OpenSprinkler was developed for Arduino; latest versions also support Rasberry Pi and similar controllers.
In the original version OpenSprinkler is controlling irrigation valves using thyristors and 24VAC transformer, this setup should work fine with my voltage converters. Alternative (and quite common) way to implement OpenSprinkler is to use Relay shield – blocks of C type relays with hookup circuitry for direct connection to Arduino or other MCU. I’m actually planning to implement OpenSprinkler this way. Good thing is that when Relay shield is used and irrigation valves are located not too far from the timer, it is possible to implement this circuit directly using the C-type relay in the shield, with no need to have an additional voltage converter (described in my prior post) on the top of it. This could be convenient.
OpenSprinkler is an open source hardware and software based on Arduino (Atmel), all schematics and source code is readily available: http://opensprinkler.com. It was designed by Ray Wang and Chris Anderson. You can either build it yourself, or you can purchase a kit (or fully assembled device) from Ray’s online shop.
There is also healthy ecosystem of hobbyists around OpenSprinkler – people are building their own versions, modifying standard firmware, exchanging ideas and help each other. There is good forum at http://rayshobby.net and WiKi.
Hardware Options
There are two main versions of OpenSprinkler available – Arduino and Rasberry Pi. I was hesitating which version to go with, and eventually decided to start with Arduino. Key reason is simplicity of interfacing with all sorts of sensors and other hardware, as well as low power consumption (this will be important for some advanced uses I have in mind). Arduino (especially Mega) has lots of GPIO pins, has mature ecosystem of various sensors etc.
RPi has limited number of GPIO pins so you have to add extra circuitry, pins are low power 3.3V and for some of the hardware (like relay shields) you need to add voltage converters etc OR buy pretty expensive modules. Power consumption of Arduino is also way lower than RPi, and there are lots and lots of shields available – sensors, actuators, relays, low-power wireless etc. – you name it.
Another option could be to use BeagleBone Black – it is a RasberryPi – style micro-machine, but unlike RPi BeagleBone Black has decent set of IO pins and an ecosystem of add-on modules (Capes). However it still consumes way more power than Atmel, and controllers for BeagleBone are much more expensive than Arduino shields. BeagleBone Black may be a good option for the next iteration of my project, but I would like to start with something leaner.
I decided to build my own version of the OpenSprinkler rather than buying a kit. Primary reason is that kits that are being sold are based on Atmega644 which is relatively weak MCU. It is amazing that Ray and Chris managed to squeeze in internet connectivity, web controls and fairly complex processing logic into the tiny controller with only 4 kilobytes of RAM (!), but there is little chance to add any significant new capabilities/features due to the lack of controller resources.
However I would like to add several new things to it, including temperature/humidity sensors, data logger, maybe water flow sensors, weather-based watering control, slave/remote controller boards etc., and I would like to have hardware with sufficient resources to do all that.
Good thing is that it is fairly easy to run OpenSprinkler on a regular off-the-shelf Arduino hardware. For example, this forum thread describes running OpenSprinkler on a standard Arduino Mega hardware, with a standard Ethernet W5100 shield and Freetronics 1602 LCD. It requires firmware modifications, but it is all open sourceJ and updated firmware is readily available.
My Hardware
I started with essentially the same hardware as described in this forum post – Arduino Mega2560 R3, Ethernet W5100 shield and Freetronics 1602 display shield. After one weekend of tinkering I got it all working with almost no modifications – I just moved LCD to a different set of IO pins to enable use of the SD card on the Ethernet shield, and that’s pretty much it.
It is great to see almost 5K RAM left (out of 8K total) available when OpenSprinkler is running – I have plenty of resources to work with. Also Mega has lots of GPIO pins (plus extra serial ports) to connect sensors and devices.
I’m planning to use regular simple Relay shield to control irrigation valves – I can just buy one for a few dollars from Amazon or other shops, and it is way easier than making my own multi-channel thyristors block. Good thing is that due to large number of GPIO on Mega I can connect 16 channels of relays and still will have plenty of IO pins for other uses.
Next Steps
I have basic hardware working. I’m planning to tweak the software a bit (I want to modify basic web server in OpenSprinkler to serve static parts of pages from the SD card), but generally it is good to go. Next step would be to assemble complete OpenSprinkler system in a suitable box with terminal blocks and get it ready for installation.
Update (6-15-14)
Last weekend I was working on the software, and added SD card support for logging and remote (WEB) access to logs. IMO for a system like OpenSprinkler it is essential to be able to have accurate logs to track when watering was happening, and just to ensure that the system is running the way you thought it is running. The code was retrofitted into the original OpenSprinkler (with Freetronics and W5100) and it seems to work OK.
I implemented logging using MicroSD card. The Ethernet shield has MicroSD card slot, and it was just a matter of adding logging functionality to the firmware. I implemented basic text file-based logging using standard SD library, it seems to work OK. In order to retrieve logs remotely I extended OpenSprinkler web server with the ability to produce web listing of log files (basically all files in /logs directory) and the ability to retrieve individual log files. It took some additional space in flash (mostly for SD card library) and it consumes about 1300 bytes of RAM extra – also mostly for SD card library. I still have about 3700 bytes of RAM free and plenty of flash space.
Alternative Firmware
There is also alternative OpenSprinkler firmware from Richard Zimmerman. This firmware is totally different, essentially rewritten from scratch, it is designed to run on RPi or on Arduino Mega. The firmware is much more advanced, with a built-in WEB server (working off MicroSD card) and slick WEB UI.
I got this firmware compiled and working on my setup as well. As the base for future work this firmware has certain advantages – much better code quality, advanced web server, logging, Weather support. However there are also disadvantages – this firmware does not support any local UI (no LCD or keys support) – which IMO is pretty important, also WEB UI in this firmware is designed for small-screen, phone operation and it looks funny on a regular screen.
I can probably rewrite the UI and I can add local LCD/buttons support, but it takes effort, also this firmware version is already kind of low on RAM and I’m afraid with addition of the local UI (LCD/buttons) I will be tight on RAM for adding more features. But it is an option.
I think I will experiment with both firmware versions and will decide which one to go with based on real-life usage experience.