OpenSprinkler Recent News and Updates (Feb 2015)

Hey, it’s March already, that means spring will be here soon! Amid an unusually cold winter and freezing weather this winter in New England, we’re finally starting to see some warm winter days. No more snow please, we’ve had enough 🙂

Ars Technica
This post is to give you some recent updates on OpenSprinkler and upcoming plans. First of all, OpenSprinkler Pi got blogged by Ars Technica, which is super cool. It’s really a fun article to read. That caused a huge spike of orders, but we managed. I only wish that Cyrus Farivar, the author, had talked about the microcontorller-based OpenSprinkler as well, because appearance-wise it looks more elegant.

Unified Firmware 2.1.3

Next, we just released the first version of the Unified OpenSprinkler Firmware, numbered 2.1.3. The biggest benefit of this firmware is that it’s cross-platform — it can compile and run on all OpenSprinkler hardware platforms, including the standard OpenSprinkler (OS), OpenSprinkler Pi (OSPi), and OpenSprinkler Beagle (OSBo). The cross-platform idea was inspired by Rich Zimmerman’s sprinklers_pi program. The purpose is to make a fully consistent firmware for OS, OSPi and OSBo, so that the same firmware and same features are available on all of them.

Technically, the unified firmware is written in C++. It’s done this way to share the code between OS, OSPi and OSBo as much as possible. The major differences are that on OS, all non-volatile memory data (such as options, program settings) are stored in EEPROM, while for OSPi/OSBO, these are stored in a local file, which simulates EEPROM. Also, OSPi/OSBo uses the standard socket to handle Ethernet communication, while OS uses an Arduino EtherCard library. Other than these, the code is largely shared between them, making it easy to extend in the future. Folks may find C++ based programs less friendly to modify than Dan’s Python-based interval_program. However, as I said, the point is to make the three platforms maximally compatible, so that any new features introduced in OS will be simultaneously available to OSPi and OSBo.

The main added new feature of this firmware is the support of using sunrise/sunset times in program settings. Specifically, the program’s first start time (and any of the additional start times) can be defined using sunrise/sunset time +/- an offset (in steps of minutes) up to 4 hours. The program preview will also take into account the sunrise/sunset time of a specific day. Another change is the support for MD5 hashed password, which attempts to address the previous plain-text password to some extent. For the security-minded, I admit that this is far from sufficient, but better than before.

For OSPi/OSBo, all features currently implemented on the OS, such as individual station water time, Zimmerman’s weather-based water adjustment, and support for radio frequency stations, are also immediately available for OSPi/OSBo.

Details on this firmware and how to upgrade OS/OSPi/OSBo to use this firmware can be found in this forum post.

Upcoming Plans
There are quite a few things on our todo list. The top items include:

  • Getting OpenSprinkler certified by the EPA WaterSense program (which requires ET-based water time calculation).
  • Support for soil moisture sensor and flow sense (at least flow estimation).
  • Improve the scheduling algorithm to better handle overlapping schedules using a queue.
  • Adding firmware support for using sensors (either digital or analog) to trigger sprinkler events.
  • Adding cloud-support (long term goal).

Some of these are purely software, but some will entail hardware changes. For example, for cloud-support, we’ve come to the conclusion that it will require an upgraded microcontroller due to the resource limitations of the current hardware. So the cloud support will likely not happen until OpenSprinkler 3.0 comes into place. It seems that adopting ATmega1284 is the most straightforward solution — it’s totally pin compatible with the current ATmega644, but doubles the flash memory space and quadruples RAM size. If you have suggestions about desired hardware changes, please feel free to let me know. This is the time that your opinions will be factored into the future of OpenSprinkler 🙂

Besides the additional new features, we are also planning to remove some features which are rarely used. One immediate plan is to remove the built-in relay, which seems not very useful, only to add manufacturing cost. The original idea of including a built-in relay is to use it for general-purpose switching, such as garage doors, landscape lighting etc. However, there is no cutout dedicated to the relay wires, so it requires some modification to the enclosure. Also, now that we have support for Radio Frequency (RF) stations, the need for build-in relay is even lower. Alternatively, you can use an external 24V AC relay, which I blogged about previously. At any rate, it seems wise to retire the built-in relay.

Retiring OpenSprinkler DIY and OSPi Standard Version
To prioritize our business, we have decided to permanently discontinue OpenSprinkler DIY kit and OSPi Standard version. We will no longer stock these kits. I know that OpenSprinkler DIY kit has been a fun product for many makers and Arduino lovers. But the maintenance cost is also pretty high — even though we do not officially provide technical support for DIY kits, in practice we still help users a lot in fixing their soldering mistakes and diagnosing issues. This has taken too much overhead, and because of this reason, we will retire the DIY kit.

As for the OSPi Standard version — it will also be retired soon in favor of the Plus version. Most of Raspberry Pi’s new products, including A+/B+/2 use the same form factor, which is not compatible with the original A/B. The standard version is still compatible if you own a RPi 1 model A/B. But we are looking into the future, and expect the orders of the standard version to drop significantly in the upcoming season.

DC Powered OpenSprinkler
I’ve received several requests to make an OpenSprinkler variant for DC solenoids. Within the US, most sprinkler solenoids are still AC powered. But for International users, it can be painful and confusing to find a AC power source, especially since AC adapters are not regulated (i.e. you can’t plug in a 110VAC adapter to 220VAC socket). In contrast, DC adapters and solenoids are sometimes more common and cheaper to source, and DC adapters are usually regulated and universal.

In a previous blog post, entitled Understand 24V AC Sprinkler Solenoids, I analyzed the electric specs of a typical sprinkler solenoid. One interesting discovery there is that it’s totally possible to drive a 24V AC sprinkler solenoid using DC voltage. The trick is that it needs a high momentary voltage to activate, but once activated, it can remain open with a relatively low voltage (some where around 6~8 VDC). This means a DC powered OpenSprinkler not only works for DC solenoids, but can work for a typical 24V AC solenoid as well. In fact, combining this with the H-bridges that OpenSprinkler Bee uses, it’s even possible to use the same hardware to drive DC Latching solenoids as well! Perhaps I can call this the Unified OpenSprinkler Hardware design 🙂

Inspired by this idea, I am actually working on a DC version of OpenSprinkler. Besides the benefits to International users, another benefit of a DC design is that this makes it easy to add a current sensing circuit to monitor each station, and detect potential solenoid shorting / damage etc.

Modified OpenSprinkler Becomes a Biology Experiment Controller

Around Thanksgiving last year, I received a request from a biology lab professor who commissioned me to modify OpenSprinkler to become a custom fluidics controller. The goal is to achieve web-based, programmable control of fluid selector valves, linear actuators, relays, and air valve, to automate a custom biology experiment. I don’t typically accept contract work, but felt this was a very interesting project, as I’m always keen to see wider applications of OpenSprinkler. Also, this particular project fits well with the existing software design of OpenSprinkler, since the control schedules are somewhat similar to typical sprinkler programs.

It took me a while to understand the design requirement and how various components worked. The main component is the fluid selector valve, which selects a specific type of fluid from several input fluid streams. The valve has a number of control wires which are normally pulled high. To set a specific position, you basically use open-collectors (one for each wire) to pull a subset of the wires to ground. This is pretty easy to achieve using OpenSprinkler — there are 8 stations on the main controller, each station is a open-collector that controls on wire. By activating a subset of stations, it sets the selector valve to a specific position.

IMG_0542IMG_0543

The project also calls for two solid state relays (SSRs) to control 110V pumps. The SSR works with logic level signals, so I used two digital pins to interface with them. Next, there are two 12V linear actuators, and a 12V air valve. Because we don’t want to involve too many different power supplies, we decided to go with a single 12V power supply, which powers the OpenSprinkler, linear actuators and the air valve. OpenSprinkler already has a switching regulator inside that can work with 12V, so that’s not a problem. I then used the built-in relay on OpenSprinkler to switch the air valve. To control the linear actuators, I needed two high-power H-bridges. The way linear actuators work is that they each have two wires — apply positive 12V on the two wires, the actuator will start to extend; reverse the polarity, the actuator will retract. This is similar to how a motor works, and it’s typically done through an H-bridge. Because the linear actuator can draw up to several amps of current, I decided to use a 4-channel relay board (instead of MOSFETs) to implement two H-bridges. So four additional digital pins are used to toggle the 4 relays.

IMG_0544IMG_0547

The right image above shows a CO2 sensor. It is used to conditionally open the air valve at the end of the experiment. The idea is that the air valve will only need to be open if the CO2 level is above a certain threshold. I didn’t have chemicals to generate CO2, but had plenty of soda at home, so it was quite easy to create varkous CO2 levels to help test the sensor 🙂

Then as soon as I started working on the software, I realized that the control schedules are actually not entirely the same as sprinkler programs. Specifically, each schedule contains multiple entries, where each entry indicates the status of every component and the time the status will last. It’s kind of like: upon starting the program, the components should be in status A, B, C; after 15 minutes, they will change to status D, E, F; and so on. So I decided to overhaul the existing OpenSprinkler firmware, and rewrite it with a new program data structure. The end result is that each program contains multiple entries. For each entry, you specify the status (such as on/off) of every component, and the duration (i.e. how long the status lasts). In a sense this can also be used to schedule sprinkler programs, and it’s actually very powerful, because it allows you to set almost arbitrary schedules, including scheduling multiple stations to open at the same time, and scheduling the same station to water multiple times within a program. So maybe once day I will make it an alternative OpenSprinkler firmware.

Anyways, it was a really fun project. I didn’t have very good documentations about the work, but I did shoot a couple of video clips. Check them out below.

The initial demo video:

The final demo video with web interface:

Using 24V AC Relays with OpenSprinkler

Back in early December last year, we introduced a new feature in OpenSprinkler Firmware 2.1.1 that allows OpenSprinkler to directly talk to remote power sockets. With this feature, you can use OpenSprinkler to not only switch sprinkler valves, but also switch powerline devices such as light, pump, heater, fan. While it’s a powerful feature, it is after all a wireless solution so it’s not the most reliable — sending wireless signals to remote power sockets is prone to interference and is limited by distance and barriers (e.g. walls, floors) in between.

If you still prefer using relays, whether because it’s more reliable, or because it’s the classic way, there are plenty of choices. I’ve often received questions about how to use OpenSprinkler with a relay. The easiest solution is to get a 24V AC relay. Then you can wire it up as if it’s a sprinkler valve — when OpenSprinkler turns on the corresponding station, the relay is activated, and that turns on the device connected to the relay. Because AC relays are not as common as DC relays, they tend to be more expensive. Here I list three choices I’ve found:

1. Omron G7L-2A-TUB-J-CB-AC24: this is available on Amazon. This is actually commonly used in sprinkler pump start relays — if you have a pump start relay, you can open it up and check if it has a 24V AC relay in side. This particular one has a contact rating of 25A @ 220VAC, which is sufficient for most applications. You can also find similar ones with different specifications: if you search for ‘Omron G7L-‘ you will find many choices, look for the ones ending with AC24, which are the 24V AC versions.

IMG_0659IMG_0661

I am quite curious how such 24V AC relays work. It probably is constructed somewhat differently from a DC relay. So I ventured to open it up. As you can see in the picture on the right above, it has a big coil, a contact piece connected via a spring. When voltage is applied on the coil, the contact piece gets attracted and therefore connecting two contact pins together. That’s how a basic relay works.

Something strange I noticed is that when I try to measure the resistance on the coil, it gives me a very large value — several mega-ohms. The coil resistance can’t be that large. There is probably additional circuitry inside the relay. I then measured the forward voltage drop on the coil, at either polarity it gives about 1.25V drop, which strongly indicates there is a bridge (i.e. full-wave) rectifier inside. This makes sense, because a bridge rectifier is a standard way to convert AC to DC. So the additional ‘construction’ inside the AC relay (compared to DC) is probably the rectifier.

To verify it, I had to open it up even further, which involves cutting some pieces of the plastic. Eventually I was able to open it up completely. Check the bottom section of the relay:

IMG_0660

Yup, there is a bridge rectifier and a MOV. Previously I was measuring the resistance through the bridge rectifier, which explained why the value I got was incorrect. Now I can measure the real resistance of the coil, which turns out to be about 294 ohm. That’s about right — under 24V AC, it will draw an average of about 80 mA AC current, which matches the specification.

So in case you are looking for a 24V AC relay to work with OpenSprinkler in order to switch high-voltage devices, this is an inexpensive (<$10) choice and is easy to find. 2. Schrack RT314524: This is a very small 24V AC relay that you can buy from Mouser or Digikey. It has a contact rating of 16A @ 250VAC, which is also plenty for common applications.

IMG_0662

3. Other choices: There are some other choices which were brought up on the forum, including a open-style panel mount 24V AC relay, and even solid-state relays (SSRs).

In any case, if you are looking for a relay to work with OpenSprinkler, the above are the ones worth considering.

Magic Smoke Seen on Some ESP8266 Modules

While playing with my ESPToy today, I discovered a rather bizarre issue. The symptom is that some ESP8266 (the ESP-01 version) modules became very hot to touch. In fact, a couple of them started smoking, and the red indicator LED started burning away! Shocking. What’s even more shocking is that these modules continue to function, as if the chip isn’t bothered by the magic smoke at all…

Not all of them have this mysterious problem. So what the heck is going on here? After some digging, I found that on the problematic ones, the tiny resistor next to the red power LED measures only 4.7 ohm?! This can’t be right. This resistor is a clearly a current limiting resistor for the LED — the LED and the resistor are connected in series between VCC and GND. A 4.7 ohm resistor means the current flowing through the LED would be somewhere around (3.3V – 2.1V) / 4.7 ohm = 255 mA! (2.1V is the typical forward drop voltage of red LED). No wonder why the LED (or resistor, or both) is smoking! Phew, that really scared me. To double check, I also measured this resistor on the good ones — they all measure 4.7 kilo-ohm. That’s about right. So clearly the manufacturer has made a mistake and this is really unfortunate. I’ve shot a video of the smoking ESP8266. See below.

esp8266_power_fail

Anyway, because some of these defective modules are shipped with the ESPToy, if you’ve bought ESPToy the past few days, you may end up getting some of these units. I sincerely apologize for this. It’s not anything I’ve anticipated. There are several options to solve the issue:

  • Option 1: let it burn (~~~). Once the LED is burned out and the magic smoke is gone, it will become open circuit and the problem is gone!
  • Option 2: if it’s scary to look at the magic smoke, or if the LED refuses to burn out, you can use a hot air gun or a soldering iron to remove either the red LED or the resistor next to it, or both.
  • Option 3: if neither option is ideal, send an email to [email protected] and we can arrange to send you replacements.

Well, this is just one of those headaches to deal with when buying goods from China. To be fair, we buy only from reputable sellers, even so, issues can happen, but we do gain more experience each time a lesson is learned 🙂

Work in Progress: OpenSprinkler Pi (OSPi) A+ will Finally Close the Gap

When I first had the idea to design OpenSprinkler Pi (OSPi), a secret motivation was that one day I figured out how to fit Raspberry Pi into the existing OpenSprinkler enclosure. Yes, it sounds silly, and you can laugh at it; but if you understand how much it costs to make an injection molded enclosure, and how difficult it is to predict the market and demand, you will see why I wasn’t quite ready to invest on a whole new enclosure for OSPi.

The experience last year has proven that OSPi is quite popular. I really enjoyed seeing the amount of community development on it, primarily due to the low cost of RPi and the flexibility in programming the RPi. We’ve also seen continued evolution of RPi, from the early A and B models to B+ and more recently A+. On the plus side, it’s exciting to see that RPi continues to become smaller and cheaper. The A+ version is now 25% smaller and you can get one for just $20. On the other hand, I am sure the different versions created some challenges in re-designing products powered by RPi. Because each version has different peripheral elements, size, screw hole locations, it’s quite difficult to design one board that fits all versions.

So in a way, I felt lucky that I wasn’t too hasty to invest on a dedicated enclosure for OSPi, because whatever I would have designed would probably not fit A+ in the end. But the lack of a dedicated enclosure has always been the major confusion about OSPi: from time to time I receive questions about why the cutouts on the enclosure do not match RPi, and then I have to explain. It’s not ideal.

Here comes the good news: with RPi A+, it looks like I may be able to ‘close the gap’ finally — that the injection-molded OpenSprinkler enclosure will finally fit OSPi, without confusing mis-alignment of the cutouts, and with buttons and LCD, just like the microcontroller-based OpenSprinkler!

Here are some pictures to show you the proof-of-concept:
IMG_0582IMG_0583
IMG_0584IMG_0585

Mounting RPi. The most dramatic change is that RPi A+ will be mounted at the back of the OSPi circuit board. This is necessary to make space for the LCD (explained below). This may look surprising, but because A+ is quite flat, there is sufficient space at the back of OSPI to fit it, except HDMI, USB, and other peripheral connectors, which I’ve made cutouts for.

There is no secret that I’ve always enjoyed solving the ‘how to fit RPi into the OpenSprinkler case’ problem. It’s like a geometry puzzle for me. Often constraints push me to think of new solutions. So bear with the nerdy side of me 🙂

LCD. Next, for the LCD I am using I2C LCD — it’s the standard 1602 LCD with a I2C module at the back. This turns out to be very important, because I2C LCD needs only 4 pins in total (VCC, GND, SDA, SCL), significantly reducing the pin requirement and saving space. You can buy these with pre-soldered I2C modules, at very small added cost.

Buttons. There is also space to fit 3 push-buttons on the right-hand side of the circuit board. The physical buttons can be quite useful for triggering events or performing manual sprinkler control.

Ethernet. Lastly, I don’t want to waste the cutout for Ethernet jack, so I even added a ENC28J60 Ethernet controller. This is a useful add-on for RPi A+, which doesn’t come with an Ethernet jack itself. It took me quite while to figure out how to re-compile the RPi kernel to support this Ethernet controller. Don’t expect it to be very fast, but it comes handy if you really need wired Ethernet connection. Most people will still prefer the WiFi dongle.

IMG_0586

One of the biggest drawback of this design is that RPi A+ will now be permanently soldered onto OSPi, because there is simply no space in height to put pin headers. This is not ideal but I can’t think of a better choice. The other potential issue is the heat dissipation of RPi — although there is some space between RPi, OSPi, and the enclosure bottom, it can become an issue during hot summer days. There is some space on the board to make vent holes, so I will see what I can do.

To summarize, this is a proof-of-concept design for OSPi A+ — it will finally make the injection-molded enclosure work perfectly for OSPi. Because this is a very early prototype, don’t expect it to be available anytime soon, although I do hope to make it ready by summer time this year.

Feedback, comments, and suggestions are welcome. Thanks!

Introducing the ESP8266 WiFi Toy (ESPToy)



Content

ESP8266 — a very low-cost and flexible Serial-to-WiFi module that has gained a lot of popularity recently. It allows any microcontroller to have WiFi capability by simply using serial communication. In a previous blog post, I demonstrated how to use ESP8266 combined with an Arduino to set up a very simple web server. This time I built a standalone gadget for prototyping called the ESP8266 Toy (or ESPToy for short). There is also a more serious web server demo in the end that shows how to serve HTML files from a SD card, and using JSON and AJAX to implement prettier web design.

You should also know that there has been a lot of on-going development for this module. For example, there is a Lua-based firmware for ESP8266, which is quite amazing. Also check out the community forum here.

As usual, a video demo first:

New ESPToy 1.2:

Original ESPToy 1.0/1.1: Youtube Video Link


ESP8266 module and ESP8266 Toy are available for purchase at Rayshobby Store.


Features

New ESPToy 1.2:

  • ESP-12 SMD WiFi module, pre-flashed with Lua firmware and a startup demo script.
  • 3.3V 250mA linear regulator.
  • Programming using the on-board mini-USB port.
  • One color (RGB) LED, one pushbutton (used as a general-purpose pushbutton as well as for re-flashing firmware)
  • Additional pin headers for connecting external components and/or breadboard experiments.

IMG_0716server_example


Original ESPToy v1.0/1.1 (retired)

  • ATmega644 @ 3.3V, 16MHz, with CH340G USB-serial converter and Arduino bootloader.
  • 3.3V 500mA linear regulator.
  • Programming in Arduino using the on-board mini-USB port.
  • One color (RGB) LED, one pushbutton, one reset button. (New on version 1.1: one additional button on ESP8266’s GPIO0 pin, useful for firmware upgrade)
  • One light sensor (LDR), one temperature sensor (TDR).
  • One 2×4 pin header to fit ESP8266.
  • Additional pin headers for connecting external components and/or breadboard experiments.

In essence, the ESPToy 1.0/1.1 is a 16MHz Arduino with some handy built-in components for easy prototyping with the ESP8266 WiFi module. Once programmed, the whole assembly can run on battery. There is also a power MOSFET on board to programmably control the power supplied to ESP. This allows you to cut off power to save battery life.

The reason I picked ATmega644 (instead of ATmega328) is that 644 has two hardware Serial interfaces. I am using one for the bootloader and USB communication, the other dedicated for WiFi. This is quite handy and allows you to use the fast baud rates. Also, 644 has twice as much memory as 328, so it’s suitable for building more complex projects.

esptoy_annotatedesptoy_2


Demos

As shown in the video above, I’ve written a few examples to demonstrate the basic features of the ESPToy:

New ESPToy 1.2:

To upload the demo Lua scripts to ESPToy 1.2, download and run the ESPlorer software. The Serial port baud rate is 9600 (default). You can open a demo script, click on ‘Save to ESP’ to save the script as a file to ESP’s internal flash memory space. The script will run right away after uploading. You can also click on ‘doFile’ to re-run the script.

  • Start-up Demo: every ESPToy 1.2 is pre-flashed with a start-up demo. Plug in a mini-USB cable, the blue LED will blink and the WiFi module will start in access point mode, creating a WiFi network with SSID ESPToy-xx. The password is opendoor. Connect to this WiFi network, open a browser, and type in http://192.168.4.1. Use the sliders to change the LED color, and click on ‘Refresh Value’ to read button status and analog pin value.
  • Hello ESPToy!: shows the Serial print function.
  • Blink LED: shows digital pin write, and delay functions.
  • Button Interrupt: shows how to set up interrupt on a digital pin.
  • Hello ESPToy Server: shows a simple HTTP web server.


Original ESPToy v1.0/1.1 (retired)

  • SearchBaud: this comes handy if you forgot the correct baud rate of your ESP8266. It loops through the common baud rates, sends an empty AT command, the detects the correct baud rate by checking the result.
  • SerialCommand: this demo allows you to send AT commands to ESP8266 through a Serial monitor. Use this demo to experiment with all the AT commands available for ESP8266.
  • ScanNetwork: this demo starts the ESP8266 in AP mode, which creates a local WiFi network (the name is ESPxxxx). Use a smart phone or laptop to log onto this network, then open a browser and type in IP adddress 192.168.4.1. You will see a webpage with a list of detected WiFi networks. Type in the ssid and password of the target network, then click on Connect. The page will redirect in about 10 seconds to show the client IP address of the module on the target network. This is pretty standard approach to get your WiFi-enabled gadget to log on to your target network.
  • WebServer: this is a simple web server demo. It serves a html webpage and uses JSON and AJAX to periodically display the analog pin values. The first two analog pins correspond to the light and temperature sensors respectively, so these two values will respond to light and temperature changes. There are also three sliders to set the color of the on-board LED. As I said before, the demo can run on battery, so this can be used as a WiFi-enabled color LED light. Thinking about a simplified version of the Philips Hue? Yup, this is a poor man’s version of that 🙂
  • WebServer_SD: same as above, except this requires an external SD card slot, so that it can serve bigger and multiple html pages from files stored on the SD card.


Preparation

The ESPToy’s source code is available on Github. Check the README file therein to get started.

Serial Port and Driver:
ESPToy uses a CH340G USB-to-Serial converter. For:

On Windows, the Serial Port name is COM? where ? is a number assigned to the USB-serial chip. On Linux, the Serial Port name is /dev/ttyUSB? where ? is a number. On Mac, the Serial Port name is tty.wchxxx.

Programming ESPToy 1.2

Instructions in this section are being re-organized. For now please refer to the ESPToy 1.2 instructions in this blog post.



Programming ESPToy 1.0/1.1 (retired)
Programming the ESPToy can be done through the Arduino IDE (tested with Arduino version 1.0.6). Because ATmega644 is not a board that appears in the stock Arduino, you will need to copy the atmega644 subfolder (from the hardware folder) to the corresponding hardware folder in your Arduino’s installation directory; same with the ESPToy subfolder (from the libraries folder).

Next, launch the Arduino IDE, select Tools->Board->ESPToy, and the correct Serial port from Tools->Serial Port (see below), then select a program from File->Examples->ESPToy, and finally click on Upload

ESPToy Arduino Library:
The RFToy Arduino library can be downloaded from: http://github.com/rayshobby/esptoy. You can either clone this Github repository, or download it as a zip: https://github.com/rayshobby/ESPToy/archive/master.zip

Pin Assignments:

  • D0: ESP power (active LOW, pulled down by default)
  • D3: push-button
  • D12: red LED (pwm)
  • D13: green LED (pwm)
  • D14: blue LED (pwm)
  • A0: light sensor (LDR)
  • A1: temperature sensor (TDR)
  • Serial: USB serial TX/RX
  • Serial1: ESP8266 TX/RX

Spare Pins: D2 (INT2), D4, D15, A2, A3, A4, A5, A6, A7

Power Options:
ESPToy can be powered by USB or an external battery. There is a battery jack that fits a standard 3.7V lithium battery. In addition, there are two battery pins (next to the battery jack) — you can solder wires to connect a 3V AA/AAA battery pack. Note that the external AA/AAA battery should not exceed 3.6V (because it’s not regulated).


Flashing a New Firmware to ESP8266

Programming ESPtoy with Arduino: I strongly recommend you to learn to use Arduino to program ESPtoy, due to its flexibility and memory efficiency. While Lua firmware is easy for beginners, to write advanced programs, it’s much easer to use Arduino. Check the resources in this forum post.

On ESPToy 1.2 and 1.1: there is a pushbutton button (on version 1.1 it’s at the upper-left corner) — it’s connected to ESP8266’s hardware GPIO0 pin. If this button is pressed when powering up ESPToy, the ESP8266 will enter bootloading mode waiting for a new firmware. I recommend using the esptool python program to upload firmware, which is very easy to use. Specifically, in command line, run
./esptool.py write_flash 0x00000 xxxx.bin
where xxxx.bin is the firmware name.

On ESPToy 1.1, use the SerialCommand sketch to prepare ESPToy as a serial relay.


For ESPToy 1.0 (retired): to let ESP8266 enter bootloader, you need to solder a wire from ESP8266’s GPIO0 pin to ground. Specifically, if GPIO0 is pulled to ground, upon power-up ESP8266 will enter bootloader mode waiting for a new firmware from the Serial interface. In contrast, if GPIO0 is pulled up (to VCC), ESP8266 will boot into normal operation mode.

The picture below shows where the GPIO0 pin and a ground pin (any ground pin on the board should work). The wire should be soldered at the back of the circuit board. You can also connect a switch in series on the wire to easily switch between bootloader mode and normal mode.

esp_gpio0

Once this is done, you can flash the SerialCommand sketch to ESPToy, which will make it serve as a Serial relay. I recommend using the esptool python program to upload firmware, which is very easy to use. Specifically, in command line, run
./esptool.py write_flash 0x00000 xxxx.bin
where xxxx.bin is the firmware name.


Purchase Link


OpenSprinkler Firmware 2.1.1 New Feature: Control Remote Power Sockets

In the past I’ve written several blog posts about how to use Arduino to interface with remote power sockets. For home automation involving powerline devices (e.g. lights, heaters, pumps, fans), this is my favorite solution, because it’s low-cost (remote power sockets are widely available at cheap price) and convenient (no messing around with relays and powerline wires). Also, one Arduino plus transmitter can simultaneously talk to many power sockets, making this a scalable solution too.

With the just released OpenSprinkler firmware 2.1.1, support for interfacing with remote power sockets has finally arrived. So you can now use OpenSprinkler not only to control sprinkler valves, but also powerline devices. Trying to find a programmable way to control your Christmas lights? Look no further! With OpenSprinkler’s easy-to-use web interface and flexible programming capability, you can enable automated control of lights, heaters, pumps, fans — anything that can be plugged into wall outlets.

Here is a quick video tour on how to get started:

Below are detailed instructions.

Required Parts:

How does this work?
Let me briefly explain how the whole thing works. First, common remote power sockets operate in the 433MHz radio frequency band. When you press a button on the remote, it sends out a signal to the power socket, which gets decoded and acted upon. If we can sniff the signal, we can use a microcontroller plus a 433MHz transmitter to replicate the signal, thus be able to directly control the power socket in software. The RFToy is a gadget that I’ve designed to easily decode signals from common remote power sockets. Once we have the code, we can use OpenSprinkler to simulate the code, thus be able to control remote devices.

Heads-up: the following steps require a small amount of soldering. The estimate time for modification is 15 to 20 minutes.

Step 1: Decode Remote Power Sockets
Take out the RFToy, plug in a 433MHz receiver (making sure the VCC and GND pins on the receiver match the +5V and GND pins on the RFToy). Follow the on-screen instructions to record the on/off signal of a power socket. Once decoded, the signal will be converted to a 16-character hexademical code.

To test if the code works, take out the 433MHz transmitter, and solder a 17cm (6.7inch) long wire antenna to the ANT pin. Then plug it into the RFToy (making sure the DATA and GND pins on the transmitter match the DATA and GND pins on the RFToy). Bend the pins as necessary. Now click button S3 or S1 on the RFToy, the power socket should be toggle on or off just like when you press the buttons on the remote. Keep in mind that although most remote power sockets work in the 433MHz band, there are some that work in the 315MHz band. In that case, just use a 315MHz transmitter-receiver pair.

Step 2: Install RF Transmitter to OpenSprinkler
Remove the OpenSprinkler enclosure, and locate the RF transmitter pinouts (marked A3 VIN GND). The pinouts are located either close to the top of the PCB, or next to the Ethernet jack. Plug in the transmitter to the pinouts, making sure the DATA-VCC-GND pins on the transmitter match the A3-VIN-GND pins on the circuit board. Then solder the three pins at the back of the circuit board, and clip as necessary. Carefully arrange the wire antenna around the LCD and re-install the enclosure.

It’s important to use a wire antenna of sufficient length, otherwise the transmission range will be severely limited.

Step 3: Final Testing
Make sure your OpenSprinkler is running firmware 2.1.1 or above. If not, please follow the firmware instructions to upgrade your firmware first. Then go to Edit Stations, select the station you’d like to use as an RF station, and change its name to the 16-character hexademical code recorded on the RFToy. Any station with a name of this form will be automatically recognized as an RF station. When the station is turned on, the controller will automatically send out the signal through the installed RF transmitter, thus turning on the corresponding power socket (and vice versa for turning off the station).

Three quick notes:

  • The normal station function still works (i.e. if there is a sprinkler valve connected to that station, it will be switched on/off accordingly).
  • Most likely you want to turn off the ‘sequential’ flag for RF stations. This is because unlike sprinkler stations, you probably don’t want RF stations to be serialized with other stations.
  • If you are short of stations, just increase the number of expansion boards. You don’t need to have the physical expansion boards (think of RF stations as virtual sprinkler valves). Firmware 2.1.1 supports up to 48 stations in total.

With this feature, you can now use OpenSprinkler to programmably switch a large number of powerline devices, such as Christmas lights, landscape lights, water pumps, heaters, fans.

Keep in mind that because this is still an experimental feature, don’t use it on anything critical (i.e. those that can cause damages if accidentally left on). Depending on the distance and obstacles between OpenSprinkler and remote power sockets, it might not reliably switch on/off power sockets. So take time to do plenty of testing before you finalize the setup.

os_rf_install

That’s it. We encourage you to try out firmware 2.1.1 and let us know your comments / suggestions / feedback. Don’t forget to post pictures of your projects. We would greatly appreciate your efforts. Thanks!

Verified: OpenSprinkler Pi (OSPi) 1.4 works with Raspberry Pi A+

As you’ve probably heard: the Raspberry Pi Foundation recently released RPi A+, which is the first RPi that’s smaller in size than any other RPi. It is essentially a B+ with less memory (256 MB vs. 512 MB), one USB port (instead of four), and a compact form factor (65mm vs. 85mm). Not only is it smaller, but it’s lighter, consumes less power, and best of all, it’s cheaper — only $20!

There is a famous Chinese saying: “A sparrow may be small but it has all the vital organs”. This is exactly what I feel about RPi A+. Although it’s almost 25% smaller than any other RPi, it retains all the essential features. Similar to B+, it has a microSD card slot, and hybrid audio / composite video port. This helps reduce the overall size of the assembly. It doesn’t have a built-in Ethernet controller and connector (which contributed to the lower price tag), but most people will likely use a USB WiFi dongle anyways so it’s not a big loss. What’s clever about its design is that it’s pin compatible with B+ — in fact it’s basically B+ with 20mm chopped off from the right edge. All the connectors, pin headers, screw hole locations are exactly the same as B+. This means any shield / extension board that works for B+ is likely to work for A+ with no modification.

Such is the case with OpenSprinkler Pi (OSPi) — the B+ version works perfectly fine for A+. Below are two pictures showing OSPi v1.4 (B+ version) with A+ installed. As you can see, it leaves extra space on the right-hand side to fit additional components.

IMG_0484IMG_0485

As you may have guessed: given the extra space, the first components I will consider adding are three pushbuttons. This makes a lot of sense. So far OSPi has been using the same enclosure as the microcontroller-based OpenSprinkler. Because the enclosure is unfortunately not tailored to OSPi, there are several cutouts left unused, such as the pushbutton cutouts, Ethernet, LCD, USB, and power switch. With the extra space on the right, pushbuttons are the easiest to add back. Ethernet controller and connector can also be added, although as I said above I am not sure how useful they are, since most people would probably prefer using USB WiFi dongle.

LCD is another popular feature that has been requested. This is a bit tricky to add because there is simply not enough space in height to fit a standard 1602 LCD like the microcontroller-based OpenSprinkler. However, I’ve got a wild idea that I think is going to work. If this is feasible, then OSPi will truly look just like the microcontroller-based OpenSprinkler. I will post an update as soon as my idea is verified. Stay tuned!

Sneak Peak Preview of SquareWear Esimal

Since SquareWear 2.0 and Mini, there will soon be a new member in the SquareWear family. This is a sneak peak preview of SquareWear Esimal — the tiniest SquareWear ever made 🙂

2014-11-14IMG_20141114_123548

How does it differ from the other two members? First, it’s tiny and measure only 1.1″ x 0.7″. It’s designed to be small, low-cost, and suitable for breadboard experiments. It has two rows of 1×11 0.1″-pitch pin headers and can fit directly onto a breadboard. Second, it uses a micro-USB connector, which helps reduce the overall footprint. Although the big sewable pins are gone (so are the built-in buzzer and rechargeable battery), the Esimal keeps the most essential features of SquareWear — it has ATmega328 running at 3.3V, 12MHz, with built-in USB port and USBasp bootloader, light sensor (using a photoresistor), temperature sensor (using a thermistor), general-purpose button, and LED. Overall it will be a very low-cost, breadboard friendly SquareWear, for learning Arduino programming, organizing workshops, and general-purpose microcontroller projects.

IMG_0479

Since this post is a preview, I will not dwell too much on the details. Expect Esimal to be available in a few weeks time!

Introducing RFToy 1.0

Today I am introducing the first version of RFToy — an Arduino-compatible gadget for interfacing with Radio Frequency (RF) modules. First, let me show you a few pictures of RFToy and a video introduction:

IMG_0419IMG_0428IMG_0426
IMG_0427IMG_0431


RFToy is available for purchase at Rayshobby Store.


Features
  • ATmega328p @ 3.3V, 8MHz, with CH340G USB-serial converter and Arduino bootloader.
  • Programming in Arduino using the on-board mini-USB port.
  • One 128×64 OLED display, three tactile buttons.
  • 20mm coin battery holder, and slide switch to select between USB or battery power.
  • Pin headers for plugging in 433/315 MHz RF transmitter and receiver modules, and MOSFET power switches for them.
  • 3.5mm audio jack to output receiver signals to a computer’s line-in port, to monitor RF waves.
  • Pin headers for plugging in nRF24L01 transceiver.
  • Pin headers for connecting external components and/or breadboard experiments.

So in essence, RFToy is a 8MHz Arduino with buttons, OLED display, battery holder. It’s compact (1.5″ x 2.3″) and it’s suitable for a variety of projects involving RF modules.

rftoy_annotated


Demos

As shown in the video above, I’ve written a couple of examples to demonstrate the basic features of the RFToy.

  • RF Recorder: this demo shows how to use RFToy to decode signals from the remote control of a typical wireless power socket, store the decoded signal in EEPROM, and play it back to simulate the remote control. You can store up to 7 different signals, allowing you to control up to 7 power sockets. The demo is based on the RCSwitch library, and it has a basic UI using the OLED display and buttons.
  • Wireless Temperature Sensor: this demo uses a pair of RFToys — one RFToy has a thermistor (connected to analog pin A1) and sends out the temperature reading periodically through its 433MHz transmitter; the other has a 433MHz receiver, and displays the received value to the OLED. This demo is based on the VirtualWire library, and uses the watchdog timer and power-down sleep to save battery life when the sensor is not transmitting data. A variant of this demo is also provided using a pair of nRF24L01 transceivers and the Mirf library.
  • Interfacing with Off-the-Shelf Wireless Sensors: previously I’ve written several blog posts about using Arduino to interface with off-the-shelf wireless temperature, humidity, rain, and soil moisture sensors. Since these sensors all work in the 433MHz frequency band, these demos can all run on RFToy, with sensor values displayed onto the OLED.

With the built-in buttons, display, and Arduino compatibility, there are tons of other projects you can build with RFToy.


User Manual

RFToy is open-source. You can check out its Arduino library code at http://github.com/rayshobby/rftoy, and hardware design files at http://github.com/rayshobby/rftoy-hw. Some technical details are provided below:

Note: the content on this page is published under Creative Commons Attribution-ShareALike (CC BY-SA) 3.0 License. Content reuse is allowed. If you have a project/product based on RFToy, please acknowledge my contribution. The software code and hardware design are published for educational purpose.


Purchase Link