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:
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!
Look at what came in the mail today:
It’s my first Raspberry Pi (Raspi)! I know I should have got it much earlier, but I was not fond of being put on a waitlist. Apparently I should have kept better track of it: I was checking some stuff on Newark.com the other day and accidentally noticed that Raspi is in stock. Without any hesitation I immediately placed an order. Three days later, it’s here!
First impression:
Gosh, it’s small! It’s the size of a credit card, and the build quality is pretty sold. It’s powerful eough to run a Linux system with X server, and it even has HDMI output so I can directly use it with my high-resolution LCD. The setup was quite easy. The machine boots from an external SD card. All I did was to grab a 4GB SD card, follow the instructions here to flash the default raspbian image onto the card, and insert it to the SD card slot on board. Then I used a micro-USB cable to power it up. I also digged out an old 3.5 inch LCD screen from Dx.com and it works perfectly with Raspi (though the resolution is low, hence it’s not really good for reading, but good for showing 🙂
Standard keyboard and mouse should work well out of box. This version (model B) of Raspi has two built-in USB ports. Of course you can use an USB hub to extend the ports. It doesn’t have a WiFi chip on board but it does have a Ethernet jack. I plugged in a NetGear WNCE2001 WiFi adapter and instantly I have WiFi connection. It also works with a variety of USB WiFi dongles, so it’s really convenient.
One of the biggest selling points of Raspi is of course its price: this model B is just $35 before tax and shipping (keep in mind that even an Arduino board, which has a must simpler microcontroller, would cost almost $30). This is totally impressive, especially considering we have to factor in reseller margins on top of the manufacturing cost. I don’t what’s the profit margin, but perhaps it is consistent with a recent article that discusses how you can’t make money any more on hardware, instead, it’s the software and service that keep consumers to buy in.
Anyways, I am glad I finally got one. There is a lot of stuff I am excited to experiment with using Raspi, and I am sure I will come up with some itneresting project ideas along the way. A thumb up for Raspi!
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!
The past month has been a bit crazy. I just completed a series of traveling from mid-July to early August. It’s really hard to get work done while traveling. The good news is that I am back now, refreshed and energized to crank out some new projects.
AASaver v1.1 back in stock
The first bit of news is that AASaver v1.1 is now back in stock and available in my hobby shop. If you’ve noticed from my earlier post, version 1.1 improves upon the original version by adding a switch to control the LEDs, so the same board can be used simultaneously as breadboard power supply and LED flashlight. Another update is that both LEDs are moved to the same side so they point to the same direction. The separate LED switch was actually a suggestion made by Michael Castor from MakerShed. So I would like to thank Michael for making this suggestion. The original plan was to sell AASaver in MakerShed. However, due to some of their policy changes, that plan fell through. Nonetheless, AASaver has been quite successful and more than 370 have been sold to date. It got posted on Hack a Day, Adafruit blog, and also got reviewed by Dave Jones on his EEVblog. Anyways, if you have any suggestions for the AASaver, please let me know and I will consider them for the next update.
434MHz RF transmitter/receiver pair
A couple of new products have also become available in my hobby shop. The first is a 434MHz RF transmitter/receiver pair. These are compatible with similar products you can find at SparkFun or other retailers. It’s inexpensive, and is very handy for implementing wireless communication for your microcontroller projects. In addition, I have been using the receiver to reverse engineer wireless power sockets, remotes, and sensors, and using the transmitter to simulate or interface with these devices. Check my blog post here for an example of how to use them. If you are only interested in the RF transmitter, you can get it separately from my shop page.
DS1307 RTC module with built-in battery
This is a DS1307 Real-Time Clock (RTC) module that has built-in 3V rechargeable lithium battery and recharging circuit. Very handy for projects that need offline time keeping. To use this module, connect four pins: Vcc, Gnd, SDA and SCL. Note that Vcc must be connected to +5V: it won’t work with +3.3V. You can find DS1307 Arduino library from the Arduino Playground, and a variety of other websites. The module also comes with an on-board 4KB EEPROM that uses the same I2C interface, a 1×4 pin header, and female-female jumpers for easy connection to your existing projects, such as OpenSprinkler kits that do not have built-in DS1307. Highly recommended!
DHT11 Temperature/Humidity Sensor
This DHT11 Sensor is the first product in the Sensors category. It is a low-cost temperature and humidity sensor that requires only one digital I/O pin to read both temperature and humidity values. Very handy as an add-on sensor to OpenSprinkler. The operating voltage is 3-5V, and measurement range is 20%-80% humidity (5% accuracy), 0°-50°C temperature (±2°C accuracy). You can find the product datasheet, an Arduino tutorial by Adafruit, and an Arduino library from the product link above. Note that Adafruit’s library does not work with 8MHz Arduino, which is what OpenSprinkler is running at. So i recommend the library at the third link on the products page.
USB-to-Serial (TTL) Converter
This product has been mentioned in an earlier post, but I just want to bring it up again since it has been very popular. It is an integrated USB-to-Serial converter based on Prolific PL2303HX chip. ‘Integrated’ means the circuit is in the USB connector itself, so it’s quite compact. This inexpensive converter is very handy for debugging and creating serial communication. To use it you usually only need to connect three pins: Gnd (black wire), TX (green wire), and RX (white wire). Keep in mind that TX should be connected to the RXD pin of your microcontroller and vice versa for RX. No driver is necessary under Linux. For Windows and Mac, follow the product link to download driver. Once installed, The device will report as a Serial COM port. You can then use ArduinoÂ’s serial monitor, putty, gtkterm, or any of your favorite serial monitor to talk to it.
So much for the product update. There will be a few follow-up posts about the update of OpenSprinkler and SquareWear. These are more major updates that I have to talk about in separate posts 🙂
Update: check out the RFToy — an easy-to-use standalone gadget to control remote power sockets. Also, support for remote power sockets have been added to OpenSprinkler firmware 2.1.1.
In previous blog posts, I’ve described two ways to use an Arduino to interface with an off-the-shelf remote power sockets / switches. The first method uses transistors to simulate button presses. It involves some soldering and hacking the remote control unit. The second method uses an oscilloscope to sniff the signal sent by the remote control, and then simulates the same signal using an RF transmitter. But what if you don’t have an oscilloscope, or don’t know where to place the probe to take the measurement? In this post, I will describe a very simple method to sniff remote control signals. It only requires a 434 MHz RF receiver, a couple of resistors, an audio cable, a sound card (with line-in), and an free audio processing software. (Note: some RF remote sockets work at 315 MHz frequency range).
Update: check out the RFToy — an easy-to-use standalone gadget to control remote power sockets. Also, support for remote power sockets have been added to OpenSprinkler firmware 2.1.1.
To get started, I picked a set of indoor wireless power sockets from Amazon. This is different from the model I had before, and it’s not based on the PT2262 encoder, so I cannot predict the RF signal by just looking at the circuit board connections. The reason I picked this model is because it has separate On and Off buttons for each socket, instead of just a Toggle button. So if you want to make sure the socket is on, just repeatedly send the on signal. With only a toggle button, if there is a power reset or if the previous command was not successfully received, you will mess up the control and end up with completely flipped on/off status.
RF Sniffing Circuit
Ok, here is the fun part: how can we sniff the signals sent by the remote control to the sockets? It turns out that most of these remote controls work in the 434 MHz band (note: some work in 315 MHz), so we can use a cheap 434 MHz RF receiver to intercept the signal. To record the signal, a simple way is to use your sound card and an audio recording software. The sound card can digitally sample the signal at high speed (e.g. 48,000 Hz), and it can record a signal over a long time, so it is more convenient than using an oscilloscope.
This is by no means a new idea. I found it when reading this forum post. Scroll down and you will see the schematic to make the sniffing circuit. One important thing is that you should plug the audio cable to the Line-In jack on your sound card, not the Mic jack.
The picture on the left is my implementation of the circuit. I used my handy AASaver to provide the +5V needed by the RF receiver. This way, the whole circuit sits on a breadboard without any external power adapter. I can easily insert it to the sound card at the back of my desktop PC.
Record the Control Signals
I used the open-source Audacity software in Linux to record the signals. All I have to do is to start recording, and press each of the 6 buttons on the remote control. Then I will zoom in and analyze the signals. Below is a snapshot:
Basically when you press a button, the same sequence is sent multiple times. Each sequence consists of two types of square waves: a long on followed by a short off, which I call a ‘1’, and a short on followed by a long off, which I call a ‘0’.
How can we find out the timing (i.e. the width) of the signal? In Audacity, if you zoom in the signal to the extreme, you will see the actual signal sample points. Remember that we know the sampling rate, which is 48000 Hz by default. So if we count the number of sample points, and divide that by the sampling frequency, then we will get the timing. For example, below is a snapshot of a short on. I counted that there are about 21 sample points, so the width of it (i.e. a short on or short off) is
Similarly, I figured out that a long on or long off is about 1300 us, which is three times the width of a short on or off. Also, there is about 12.5 ms delay before re-sending the same sequence. These timings don’t have to be very accurate.
With the timings figured out, I can now write down the complete sequence corresponding to each button:
Each ‘1’ is a 433 us on followed by a 1300 us off, and each ‘0’ is a 1300 us on followed by a 433 us off. The first 4 bits indicate socket on/off, the next 8 bits are always the same, and the 4 bits following from that indicate the index of each socket.
With these patterns recorded, I can reproduce the signal using an Arduino and a 434 MHz RF transmitter. The RF transmitter has one data pin, which can be connected to any Arduino I/O pin. Since there is a little bit of overhead when using Arduino’s delayMicroseconds function, I reduced the short delay time to 410 us. This way, the signal generated by the code is almost identical to the that produced by the remote control.
Download
Download example Arduino code here. This example program assumes the RF transmitter data pin is connected to Arduino pin D3, which you can change at the beginning of the file.
Use OpenSprinkler to Control Power Sockets
Now that my Arduino can talk to the remote power sockets, how about adding Internet-based control? For example, sending control signals through a web interface, or even setting a time schedule to turn on or turn off sockets automatically during a day? Aha, my OpenSprinkler is perfect for this purpose. There are two reasons, first, the OpenSprinkler is an integrated circuit that includes ATmega328 + Ethernet + LCD + USB programmer; second, the latest OpenSprinkler software provides a nice web interface where you can set an interval schedule or switch to manual control mode. All that I have to do is to connect the RF transmitter using one of the available pins on board, and then add a few lines of code to send the RF signal wherever the corresponding sprinkler station is turned on or off. This way, I can easily use the same web interface to control power sockets. Internet of things instantly!
The image above shows my implementation. I used a half-built OpenSprinkler, with everything except the switching regulator section and the solenoid driver section. The RF transmitter is connected to the controller using three wires. Again, one of the nice things is that I can directly use the software already written for OpenSprinkler, to set a time schedule for automatically turning on or off power sockets. In addition, I can switch to manual control mode, which also has built-in timers.
What’s Next?
My next plan is to use the sniffing circuit to reverse engineer RF signals sent from wireless temperature, humidity, and rain sensors. This will allow me to use an Arduino and a RF receiver to decode the wireless data and get local temperature, humidity, and rain information. Of course the tricky part is to figure out how the data is encoded. So I will have a couple of posts in the next week or so about RF hacking. Stay tuned!