OpenSprinnkler Firmware 1.8.1 Released

I had the urge to send this out a week ago, but I was holding on to it because I had to hear some feedback, suggestions, and issue reports from the initial users. Now I am ready to spread the words:

OpenSprinkler Firmware 1.8.1 is available for download in GitHub, go for it!

If you haven’t updated firmware before, here are the Firmware Update Instructions.

As always, the first question I need to answer is: what’s new in this version? Here is a list of highlights:
• New features:

  • Custom station names: each station can have a custom name up to 12 letters long.
  • Per-station master operation control: each station can individually activate the master station.
  • Run-once program: similar to the manual override feature on some sprinkler timers.
  • Station delay time, and master on/off adjusted time: fine tune station turn-on and turn-off time.
  • Water level/percentage: globally scales water time up and down based on local weather conditions.
  • Automatically reconnect: improves reliability on unreliable networks.
  • Support for RTC and automatic RTC detection: keeps time running even when power or network is lost.
  • Full range of time zones: living in Nepal? No problem.

• Improved features:

  • Program now has an ‘enable’ flag which allows you to enable or disable each program individually.
  • Improved Graphical Preview feature, which shows each station’s name and scheduled on/off time.

So this is another major upgrade since Firmware 1.6. So what happened to Firmware 1.7? Well, that was a quick update for the preparation of OpenSprinkler 1.4 orders: except for added support of RTC, it didn’t have any major changes. So I had to number this one 1.8 to distinguish it from the previous version.

Also taking a suggestion from the Forum, I’ve starting using minor revision numbers (1.8.0, 1.8.1 etc.) to keep track of changes in between major releases. This way you can easily find out whether your version is up to date.

I’ve also made a video tutorial (above) for those who want a video guide on how to use this firmware. I ended up having to switch between different ways of recording, so the audio quality is not consistent. Sorry about that, and enjoy the video!

OpenSprinkler Hardware v1.4 Released

About two weeks ago we started shipping out OpenSprinkler v1.4, and I figured it is now time to write a short post to announce it. What are the new updates in v1.4?

• DS1307 RTC
The main update is that the external EEPROM (24LC128) is replaced by a DS1307 Real-Time Clock (RTC). I am aware that RTC has been requested since the beginning of OpenSprinkler, and I apologize for taking so long to add it. There are multiple reasons: the limited PCB space, the cost of DS1307, and the fact that NTP sync is often good enough. The limited PCB space is probably the biggest reason. Fortunately since the latest interval program does not use external EEPROM any more (i.e. everything is stored in internal EEPROM), there is now space to add RTC. The software has also been updated to support DS1307. Specifically, if RTC is enabled in options, the controller will not rely on NTP to get time any more. In addition, there is an on-board button cell battery which will keep the time running even when power is lost.

If you own a previous version of OpenSprinkler which does not have built-in DS1307, you can easily add an external RTC module, available in Rayshobby shop. Our module comes with a built-in rechargeable battery, pin headers, and jumper wires for easy connection to your OpenSprinkler board. Follow this link for instructions on how to connect. These modules are also available on eBay, or Adafruit, or SparkFun, but they are usually pricier and without jumper wires.

• Screw Terminals
As you may have noticed from the pictures, the screw terminals have been upgraded to the two-piece (plug and socket) type, which makes it easier for installing and uninstalling wires. Now when you need to make changes to wires, you can simply take out the plug piece, insert and tighten wires, and plug it back in. There is no need to open the enclosure.

• Pin Changes
The second update is that a few pin assignments been changed to free up analog pins A2 and A3. These pins are precious for connecting to external sensors. Also, digital pin D3 is now wired internally to the rain sensor, so you no longer need to solder a separate wire. As in previous version, if you are not use the RFM12B transceiver, digital pins D2 and D10 are also free to use.


• Surface Mount Version
The last major change is that there is now a surface mount (SMT) variant 1.4s, which uses the same circuit as the through-hole version 1.4u but most components have been changed to surface mount package. This variant is created to improve our productivity of full assembled and tested kits. So from now on, all orders of fully assembled kits will receive the SMT version, while the DIY kits will continue to use the through-hole version.

The images below are close-up views of the SMT version (front and back):

As you can see from the front image, most components are surface mount, except the peripheral components like screw terminals, connectors, buttons, and big capacitors. Two crystals and the button cell battery for RTC are on the back side. The SMT version uses the same software as the through-hole version, but it does have a few differences:

  • It has two extra analog pnis A6 and A7, which are accessible in Arduino programs.
  • The Ethernet connector is changed from SparkFun RJ45 jack to Hanrun 911105A, which is less expensive and more widely available.
  • There is a slide switch on the top-left corner of the PCB. This is used internally by us to switch between programming ATtiny45 and ATmega328. You should keep it in the ‘INT’ position.

Future Plans

To give you a heads-up, version 1.4 is likely to be the last one in this hardware generation, and will also be the last through-hole version. The next version OpenSprinkler 2.0 will be SMT only, and will switch to a completely different microcontroller in order to accommodate new features like better user interface, on-board wifi, logging, and more sensor options. However, the development of 2.0 will likely take more than a year, so it won’t be available until after summer next year (2013). Meanwhile, feel free to send me comments and suggestions on how to improve the OpenSprinkler functionality, and I will consider them for version 2.0!


OpenSprinkler Hardware v1.3u Released

Ok, this post is a bit late, as 1.3u has already started selling since Tuesday this week. Anyways, 1.3u is a minor revision since 1.2u. There are only a few changes (see Release Notes for details), so I didn’t make a release video. This post explains why these changes were made and some of the technical details.

  1. Added shift register OE (output enable) line
  2. This is mainly to address an issue with 74HC595 shift register that on powering up the output values are undefined. This can potentially lead to valves being randomly turned on for a short period of time before the mcu takes over and clears output values. It is not a huge issue, but quite annoying. It turns out that one simple solution is to add a control line to the 74HC595 OE (output enable) pin. This pin is active low, which means when set to low it enables output, and when set to high, it forces the output to be in high-impedance state, therefore the triacs will not turn on and the valves will remain closed.

    In 1.3u, Arduino digital pin 3 is assigned to control OE, and a pullup resistor is used to pull the pin high by default. On start-up, before the mcu takes over, OE is high, disabling output; then when the mcu completes initialization, it sets OE to low, enabling output. That’s it. Simple solution.

    Because of the added line, the extension board connector has been changed to 2×4 format (previously it was 2×3). If you own a previous version of OpenSprinkler and would like to use 1.3u extension board, you just need to solder a wire between the OE pin and Gnd , in order to enable output by default.

  3. TXD/RXD are now used as general I/O pins.

    This change was made to free up the A2 and A3 analog pins, since there have been many requests to make more analog pins available in order to connect external sensors like temperature and humidity sensors. Because TXD and RXD are now used as general I/O pins, they can no longer be used for Serial communication. In fact, since they are not used to control the LCD, calling Serial.begin() or Serial.print will cause the LCD to display garbage. If you need Serial communication, you can use the SoftSerial library which can simulate Serial communication on any pins.

  4. Added coin battery holder.

    Warning: this is a feature under development. It requires software support which is not available yet. The goal is to have a backup battery which allows the mcu to continue time keeping even when power is lost. Actually the easiest solution would be to just add a DS1307 Real-Time Clock (RTC). But my main hesitation is that DS1307 is quite pricy. Well, it’s not hugely expensive, but at $2 a piece (volume pricing), it is actually more expensive than the ATmega328 mcu. Isn’t that a bit silly? Anyways, the time keeping business can be well handled by the mcu itself. First, the mcu can run at a voltage as low as 1.8V, so when power is lost, it can continue running on a low-voltage battery; second, during power loss, the mcu will mostly be in sleep mode, using an external 32.768 kHz clock source, and occasionally waking up to update the time counter. This way, it can basically do whatever the RTC chip can do.

    The only tricky part is detecting power loss (which is already possible with the Power Sense pinout), and turning off peripheral components such as the Ethernet controller to minimize power consumption during sleep mode. These require some further experiments, which have been put on my todo list.

Another minor change is adding two resistors for the LEDs on the RJ45 Ethernet connector. In OpenSprinkler v1.1 and v1.0, the Ethernet connector did not have built-in LEDs. Then when I changed to use SparkFun’s RJ45 in v1.2, I forgot that it actually has built-in LEDs… So in this version the LEDs are wired in, which makes the circuit more complete 🙂

That’s all for OpenSprinkler v1.3u update. In case you are wondering about the frequent hardware changes, keep in mind that we are continually improving the design based on feedback and comments received from users. We run small batches (a couple hundred) for each version, that’s why we can have quick turn-around time in integrating new hardware features. At some point when the hardware becomes mature, we will make a surface mount version to improve the production throughput. Hopefully that point won’t be too far away!

OpenSprinkler New Interval Program (fw1.6) Released

I am glad to announce that the new interval program has been released and available for download at the OpenSprinkler GitHub page. This is a major software update since the initial release in October last year. Here is a list of new features in this version:

  • Program-based scheduling. Each program consists of a set of days (including weekdays, odd/even day restriction, and interval days), stations, start, ending, interval, and water time. The firmware supports up to 64 programs.
  • Choice of running stations either sequentially or concurrently.
  • Graphical Preview of each day’s program.
  • Integrated Manual Mode. When activated, the manual mode allows turning on or off stations using buttons on the homepage. An optional timer can be set to automatically shut stations off.
  • Support for rain sensor and location-based weather checking.

Details can be found in the video below, and the OpenSprinkler Instructions of Use page. This software version is compatible with all existing hardware versions, including v1.0, v1.1, and v1.2u. Feel free to give it a try. To find out how to re-program the MCU with new firmwares, please refer to the Re-programming Instructions. From now onw, the new interval program will replace the previous svc_full_schedule program, and become the default program shipped with all pre-flashed MCUs.


Technical Details

You will find that the new program has significantly improved the web user interface. This is made possible by using external Javascripts. As I described in a previous post, a major challenge in designing full-featured web interface is the limited program memory (flash) size of the ATmega328 MCU. The trick to get around with this limitation is by using external Javascripts stored on remote servers to ‘beautify’ the webpages. When you access the OpenSprinkler webpage in a browser, two pieces of information are combined in the browser: one is the essential data provided by the controller, the other is the set of Javascripts used to format webpages. The process to combine the two actually happens in your browser, which can interpret and execute complex Javascripts. This is called Client-Side processing. In addition to releasing the MCU from carrying the heavy ‘formattting’ code, another advantage of this separation is that you can easily replace the Javascripts to present data in a different format. This is in a sense similar to web Templates. Finally, debugging Javascripts is also a lot faster and easier than debugging microcontroller code, because it requires no re-flashing of the MCU, and most modern browsers support checking and error reporting of Javascript code.

One downside with this approach is that the Javascripts must be placed on a server that’s constantly available. Currently the scripts are stored on the Rayshobby web server, which is quite reliable. The path to the scripts is:
http://rayshobby.net/scripts/java/svc1.6/
There are 7 scripts involved: home.js, progmode.js viewoptions.js, viewprog.js, plotprog.js, modprog.js, manualmode.js. These are used to format various pages, including the homepage, program modification page, program preview page etc. However, if you ever want to customize the Javascripts yourself, you need to make a copy of these scripts and put them on your home server, a cloud server, or any file hosting server that can provide direct file access links. Note that the Javascript files are simply text files that store (human-readable) Javascript code. So any server that can host a text file is ok. If you decide to direct the scripts to your own server, simply modify JAVASCRIPT_PATH macro defined at the beginning of interval_program.pde, and point it to your new path.

You don’t have to worry about the security of using scripts stored on the Rayshobby server. Remember, in client-side processing, your controller data is never sent to the server; rather, it is sent to the browser that you are using to view the webpages. The browser will then retrieve the Javascripts and combine them with the data to present the webpages. Clearly there is no way we can ‘log’ your data or keep a record of your data, so it’s safe.

The Weather feature you saw in the demo video above is implemented using a Python script and Google Weather API installed on the Rayshobby server. This is an example of Server-Side processing, because the Python script runs on the server and not in your browser. The reason this requires server-side processing is because first, the Google Weather API returns fairly long XML data that cannot be directly parsed by the MCU, second, the MCU needs to periodically retrieve weather data, so it needs to initiate requests on its own and cannot rely on the existance of a web browser. Thus the Python script serves as a mechanism to convert complex XML data to microcontroller-readable format, and since it runs on the server, the microcontroller can send requests to it at any time.

OK, so much for the technical details. There is no way to cover all details in a single post. If you want to find out more about how the software works, please refer to the source code, or post a message on the forum.

OpenSprinkler Circuit Design Notes

Over time I’ve received some questions regarding the hardware design of OpenSprinkler. Here are some common questions and my answers:

Why using a switching regulator?
Since OpenSprinkler uses a single power supply (i.e. 24VAC sprinkler transformer), it is necessary to step down 24VAC to 5VDC and 3.3VDC in order to provide power to the circuit. The simplest and most common way is to use a 7805 linear regulator. But here is a catch: due to the relatively high current consumption of the ENC28J60 Ethernet controller, the whole circuit draws about 150 to 180mA current during operation. Using a linear regulator in this case will cause a lot of power waste. Specifically, (24-5) * 0.18 = 3.42 Watt will be wasted on heat due to the voltage conversion. This is pretty bad. That’s why I made the conscious decision to use a switching regulator to achieve higher efficiency. The switching regulator in this case is estimated to have 75% efficiency, so the power waste is more like (5 * 0.18 / 75% – 5 * 0.18) = 0.3 Watt. Much better and green!

Why having both 5VDC and 3.3VDC supply voltages?
This is because the LCD requires 5V supply, and the rest of the circuit requires 3.3V. The microcontroller can work with both voltages, but the ENC28J60 Ethernet controller and the RFM12B transceiver require 3.3V. That’s why the circuit provides both 5VDC (VIN) and 3.3VDC (VCC).

Why using triacs to control solenoids? What about relays?
While a lot of other sprinkler control circuits found online use relays to switch solenoids, I made the conscious decision to adopt triacs. There are many reasons this is more preferable. First, triacs are semi-conductor components, so they are much smaller than relays, more durable and act much faster. Second, they are low-cost and significantly cheaper than relays. Third, they are also slightly more power efficient: each triac requires only 5 to 7 mA holding current to switch on solenoids, while relay coils often consume more current. In fact, a sophisticated design can use an AC triggering circuitry to trigger triacs only during zero crossings, further reducing the power consumption. All in all, triacs are great choices for switching low-voltage AC devices.

Why does OpenSprinkler v1.2 adopt a USBtiny programmer?
If you’ve noticed, the previous versions of OpenSprinkler relied on external FTDI programmer. That was designed to be compatible with standard Arduino and variants. The main advantage of FTDI is that it not only does re-programming, but also it is a USB-to-Serial converter, which allows the microcontroller to easily send and receive messages from your computer. However, it also has two main downsides. First, it is expensive: an FTDI programmer or cable can easily cost more than 15 bucks, and we don’t like to stock it due to the cost. Second, using FTDI requires a bootloader, which takes away some (512 bytes) program space from ATmega328. Therefore we have decided to go with an on-board USBtiny ISP programmer based on ATtiny45. We like this solution a lot better because this way every OpenSprinkler board has a built-in USB programmer, so you don’t need to worry about purchasing a programmer separately. It is low-cost and does not require a bootloader, so it’s a win-win choice.

OpenSprinkler Interval Schedule Program First Version Released

The initial version of the interval schedule program is now available for download in my GitHub page:
https://github.com/rayshobby/opensprinkler

Note that all demo programs are moved to the Libraries->OpenSprinkler->examples directory. This makes it easy to load a demo program in Arduino. For example, once you put the OpenSprinkler library in your Arduino’s Libraries path, you can access a demo program by following the screenshot below:

And here is a screenshot of the interval schedule program:

Basically, it allows you to set an interval and duration for each station. In the above example, stations 1 and 2 are scheduled to be on for 20 seconds every 4 hours, stations 3 and 4 are scheduled to be on for 20 seconds every 6 hours, and the remaining four stations are scheduled to be on for 5 minutes every 50 minutes. So it’s pretty simple.

An added feature is that if more than 1 stations are scheduled to be on at the same time, they will be serialized: in other words, the controller will turn on each station one after another instead of simultaneously. The serialization is activated by setting the Multi-Station value to 0.

The program is still in a primitive state, and I am working to strengthen it so that it can support a weekly schedule. Basically, the idea is to allow the user to add any number of schedule items, where each item contains a list of selected stations, days in a week, start time, end time, interval, and duration. For example, you can specify an item like ‘schedule stations 1, 2 and 5 for every Monday and Wednesday, start at 8am and end at 6pm, turn them on for 5 minutes every 4 hours’. You can add as many schedule items as you want, or modify them later. This will make the OpenSprinkler schedule algorithm significantly more flexible and powerful. So stay tuned!

OpenSprinkler v1.2u to Debut at Maker Faire Bay Area this weekend

Yup, you heard it right, version 1.2u of OpenSprinkler will debut at Maker Faire Bay Area on May 19 and 20. If you are going to Maker Faire, you are welcome to drop by and see our live demos. I started working on v1.2u shortly after releasing v1.1, and we were lucky to get the PCBs and components just in time for Maker Faire. The PCBs and components are shipped directly there, so it is not yet available for online purchase until May 23. But it is available for purchase at the Maker Faire and will be available online shortly after that.

So what’s new in this version? The main improvement is an on-board USB programmer. Specifically it’s a USBtiny ISP programmer built on a pre-programmed ATtiny45. USBtiny is one among many choices to directly program an AVR microcontroller without using a bootloader. The main advantages are that it is low cost (costs just a couple of dollars) and it enables the entire program space on ATmega328 (since no bootloader is needed). It is based on a post by Tequals0 and this version makes use of the internal clock and PLL on ATtiny45 to implement USBtiny with only three external resistors. Very elegant. With the on-board USB programmer, you don’t need any external programmer any more. Note that this version is named v1.2u, where u refers to the USB connectivity.

The second change is that some components have been replaced to adopt more common parts, including the switching regulator, the Ethernet jack, and the LCD. Also, there is now a rain sensor screw terminal, and a pinout for sensing power loss. The program will be updated to support these features soon. Another change is that the LCD pin assignment is slightly modified to free up analog pin 1, which is useful for talking to sensors. Finally, the extension board connector is also updated to use more common 2×3 pin header and cable. Note that this is still compatible with the previous version of extension board. If you have the previous version of extension board, it still works with v1.2u by switching a pin on the extension cable.

If you are interested, check the detailed release notes here and the release video below.

OpenSprinkler is going to Maker Faire Bay Area

You heard it right: we are going to this year’s Maker Faire at San Mateo, California on May 19 & 20!

Maker Faire 2012

We will be giving live demonstrations of the OpenSprinkler, AASaver, and two exciting upcoming open-source projects: OpenSprinkler Bee (battery-operated sprinkler controller), and SquareWear (a compact wearable electronics platform). If you are planning to go to Maker Faire, please make sure to drop by our booth (Maker # 7870). If you haven not decided, Maker Faire is a really fun event. You won’t regret it. So make your travel plan today!

OpenSprinkler v1.1 Released

After several weeks of hard work, I am excited to announce that OpenSprinkler v1.1 is now available!

So what’s new in this version? The biggest improved feature is hardware support for arbitrary (>8) number of stations through extension boards. This was actually quite easy to implement: the main hardware change is added pinouts for the 74HC595 shift register, which allows cascading additional shift registers to expand the number of stations. The latest software has also been updated to generically support any number of stations. So this leads to a very economic way to expand the number of stations, which is often very expensive with commercial sprinkler timers.

Another change is that the station terminals now use a common wire + individual station wire design, compatible with commercial sprinkler timers.

Other minor changes include an added 750mA fuse for current protection, and added RTC pinouts to support external I2C RTC breakout board.

Check detailed Release Notes here. The kit is now available in my hobby shop. You can get it either as a DIY kit, or a fully assembled and tested product. Detailed assembly instructions can be found here.

V1.1 Update Video

Link to the previous (v1.0) release video.


OpenSprinkler Software Update

The OpenSprinkler software (specifically svc_demo and vc_simple_web) have been quite outdated since October last year, and I am increasingly unhappy with the issues in them. I’ve also received several requests for added features and improved user interface. Over this weekend, I have finally pulled myself together and made some updates to these programs. Here is a list of major changes:

  • Created the OpenSprinkler Arduino library, which makes it easy for code re-use.
  • Added support for arbitrary number of stations. This is probably one of the most common features requested, and it’s now generically supported in software. This will go well with the upcoming hardware update v1.1. The main additions of v1.1 are on-board pinouts and connectors to link extension boards. Each extension board consists of just a shift register, triacs, resistor networks and terminal blocks. So this is a simple and inexpensive way to scale up to potentially a large number of stations.
  • Added a self-test mode and removed the manual schedule mode. The self-test mode can be activated by holding button B1 during startup.
  • External EEPROM now stores data in NOT format (i.e. ~value instead of value), eliminating the un-initialized EEPROM issue.
  • The new svc_button_ctrl and svc_full_schedule programs. These make use of the new OpenSprinkler library and replace the previous svc_simple_web and svc_demo programs (which are now in the archived folder).

You can get a copy of the updated programs from my GitHub download page. They are backward compatible with the previous version of OpenSprinkler, so you can feel free to give them a try on your current hardware.

In order to use the OpenSprinkler library, just copy the library folder to your Arduino’s libraries directory, and then in your main code, add:


#include<OpenSprinkler.h>
OpenSprinkler svc;
void setup() {
  svc.begin();
  svc.options_setup();
}

This will create an OpenSprinkler object called svc. Check OpenSprinkler.h in the library folder for all class member functions, and the svc_button_ctrl and svc_full_schedule for examples of writing your own code. A few simpler examples will be added to the library later.

The hardware update v1.1 will be available in a week or so. I am still finishing up some documentations, but that shouldn’t take long.

For the curious ones, here are some screen shots of webpages from the new programs. These examples show 24 stations:

svc_button_ctrl

svc_full_schedule