Feed on
Posts
Comments

A couple of new products have been just added to Rayshobby Shop page. These include a 434MHz RF transmitter and a USB-to-Serial (RS232) converter.

So what are they good for? The 434MHz RF transmitter is a general-purpose RF transmitter with on-board PCB antenna. It is compatible with SparkFun’s 434MHz RF transmitter. You can find a lot of example code online, including Arduino code. The module has three pins: Vcc, Gnd, Data. The operating voltage is 3~12V (5V standard), and the current draw is about 5-15mA. The higher the voltage, the longer the transmission range. Typical transmission range without external antenna (i.e. using on-board antenna) is 160 feet; and it extends to 500 feet with an external antenna. I’ve shown an example use of the transmitter in a recent article A New Way to Interface with Remote Power Switches. It provides a simple way for a microcontroller to switch wireless power sockets. Very handy and inexpensive for home automation projects.

The USB-to-Serial converter is an integrated cable based on Prolific PL2303HX chip. It is a convenient tool for microcontroller to host communication through USART. It is similar to an FTDI cable, but at a significantly lower price. It doesn’t have a Reset line though, so it cannot be used for re-programming Arduino or OpenSprinkler v1.1/v1.0. However, it is very handy to connect to your OpenSprinkler v1.2’s TXD/RXD pins in order to easily debug your code. The cable length is 3 feet (1 meter). The wires are colored as follows:

Red->+5V supply, Black->Ground, Green->TXD, White->RXD

On Mac or Linux, you don’t need to install any driver: it is already supported by the operating system. On Windows, you can download the driver following the link here. Once installed, the device will report as a Serial COM port. You can then use any Serial Monitor to communicate with your microcontroller. Some standard serial monitors are Arduino’s built-in serial monitor, Putty, or gtkterm (on Linux). I’ve been using this converter a lot for printf debugging of OpenSprinkler code.

Again, both of them are now available for purchase on Rayshobby Shop page.

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.

I just finished a batch of ordering yesterday, and felt that it would be fun to document my favorite distributors, suppliers, and PCB manufacturers. This is basically a review of some websites and stores that I regularly buy electronic components, supplies, and PCBs from. It’s suitable for buying in small to medium quantity (i.e. a few to a few hundred). When rating them, I consider a combination of factors including price, easiness of choosing parts, and shipping time and cost. Keep in mind that I am located on the east coast, so shipping cost and time may be different for you. Also, there are some negative reviews, you have been warned 🙂 Hope my comments and recommendations will be useful for other hobby makers.


Components

First of all, Octopart is a great distributor search engine. If you know the part number, you should definitely check with Octopart to compare prices across many distributors.

1. Digi-Key: one of my favorites.

  • Part selection: very easy, most components have high-quality pictures and datasheets. You can sort by price with a given quantity. Also, they have a comprehensive selection of components. Most parts I need can be found easily.
  • Shipping: inexpensive and extremely fast. They offer USPS first-class and priority shipping. If I order by 9pm EST, the order is shipped the same day, and arrives on the third day after shipping. Also, keep in mind that USPS delivers on Saturday as well. So if I missed something and need it in a hurry, I can order by 9pm EST on Thursday and still get the parts Saturday morning. For a small order (weighs 13 oz or below), I just choose USPS first-class, and that usually costs 3-4 dollars. I am basically getting the speed of Fedex 2-day service but with a fraction of the cost. Super! One of the main reasons I prefer Digi-Key.
  • Pricing: competitive for many categories: microcontrollers, capacitors, resistors, inductors, terminal blocks, just to name a few. The price can be higher than other distributors if you only buy in small quantity. However, considering the low shipping cost and fast shipping time, I would still definitely go with them for getting a few prototyping parts.
  • Customer service: excellent. I had to return an order once and it was processed quickly without hassle. Also, there were a few times that I needed to remove or add a few parts after ordering, and I was able to do these quickly through online chatting. Great customer support.
  • I use them for: getting a small quantity of prototyping parts, or buying a large quantity of microcontrollers, capacitors, resistors, inductors, terminal blocks etc.

2. Future Electronics: one of my favorites.

  • Part selection: not that easy, many components have datasheets but are missing pictures and certain information. Trying to find a part without knowing the part number can be tricky. They don’t have a comprehensive selection of components like Digi-Key, but they seem to carry a wider variety of SMT parts. You can sort by price. My suggestion is to use Digi-Key to search and find the part you want, and then check with Future Electronics to see if they have it available.
  • Shipping: very inexpensive for buying relatively large quantity, and very fast. They offer flat-rate shipping ($9 for Fedex Ground, $15 for 2-Day, and $33 for Next-Day service). No matter how many components I put in the order, the rate is the same. The package is shipped the same day if I order by 10pm EST. Very convenient.
  • Pricing: extremely competitive. This is where I find the lowest price. Often their single-item price is lower than the volume price found elsewhere. Super! I usually go with them for buying various ICs, capacitors, crystals, diodes, transistors, LCDs, IC sockets, pin headers.
  • Customer service: pretty good. They assign a customer representative for you, although it could take time to get response from them. Select parts carefully before ordering, because return can be tricky.
  • I use them for: buying a batch of ICs, capacitors, crystals, diodes, transistors, LCDs, IC sockets, pin headers.

3. AVnet
I have only used them twice, so I don’t have much to comment on.

  • Pros: competitive price, flat-rate shipping.
  • Cons: not easy to select parts. Again, it helps if you have the part number ready.

4. Arrow

  • Pros: competitive price, flat-rate shipping.
  • Cons: not easy to select parts. Customer service is problematic: one email about a return got no response.

5. Mouser

  • Pros: good price, wide range of parts.
  • Cons: shipping is expensive and unpredictable. Cut-off time for same-day shipping is much earlier compared to Digi-Key or Future, and the shipping cost always comes out higher than I expected. After a bad experience with the customer support (an email got no response in the end), I stopped using them. I know many people use Mouser for their competitive price. Frankly, if price matters, look for Future Electronics, AVnet, Arrow, or Verical. They are cheaper than Mouser and have flat-rate shipping, so you won’t get ripped off by unpredictable shipping cost.


PCB

For ordering PCBs, I highly recommend Seeed Studio Fusion PCB service. They are awesome: their service is low-cost, high-quality and fast. Yes, it’s a company located in China, so shipping can take longer time. But they process orders promptly. I usually order on Sunday evening (which is morning in Chinese time), and my order is in production the same day. Manufacturing takes 1 week, and shipping takes another week (I go with express mail options). If you don’t mind waiting for 2-3 weeks, you can get free International shipping with orders of $50 or above. If time matters, pay the extra $20-$30 to get DHL, which delivers in a week. That’s a total of two weeks to get PCBs delivered to your door. Plus, you get free DHL for orders of $500 or more. I generally use them for all PCB orders, whether prototyping quantity (i.e. 10), to batch quantity (a few hundred).

I’ve also used Advanced Circuits. They are US-based company, reliable, and extremely fast. Their price can be expensive, especially if order quantity is less than 200. I use them when I need a batch order of PCBs in a hurry and cannot wait for international shipping.


Supplies and Materials

  • Amazon: you will be amazed how many things you can get from Amazon. I get all sorts of things ranging from shipping tapes, labels, scales, to protective gloves, plastic organizers, to solder, copper board, electric wires, to cartridges, sprinkler solenoids etc. Get an Amazon Prime membership and you will receive most orders with 2-day shipping for free.
  • Techni-Tools: they have a wide range of soldering tools, solder bits, SMT soldering tools, wipes, conductive foam. Price can be expensive, but I am happy to invest on high-quality tools that I can use for a long time.
  • All-Spec: I get tweezers and all sorts of polybags, mylar bags from them. Very competitive price, and fast shipping.
  • ShippingSupply: I get most of my corrugated shipping boxes from them. Shipping cost can be a bit expensive. So buy in large quantity and stock them.
  • ULine: I get some corrugated boxes, and lots of labels from them. Good price, very fast and low-cost shipping.
  • eBay: eBay is a great place for getting things for cheap, and things that are hard to find elsewhere. Last year I bought Pogo pins, lead-free solder paste, RF transmitter modules, shipping label printer, and a bunch of home improvement store coupons on eBay.


Post-Maker Faire Update

The trip to Maker Faire Bay Area this year was a great success. This is the first time that I participated Maker Faire as a commercial maker. The two-day event was completely overwhelming to us. I was basically talking to people non-stop: showing demos, explaining technical details, outlining future plans, answering questions, and of course also accepting payments and handing out kits. It was a wonderful experience. I am really glad to have made new friends, many of them gave me generous comments, feedback, and encouragements. That’s the most fun part of the Maker Faire — connecting to people and discovering new ideas. Perhaps the only thing I felt sad about is not being able to go around and check other makers’ exhibits. We were so occupied at our own booth that I barely had any time to even get water. So tips for next time: bring a lot of water, and food too 🙂


(Above: picture at the Maker Happy Hour.)

So what’s happening with OpenSprinkler since Maker Faire? Well, first of all, fulfilling orders and responding to questions have taken a lot of my time. Then, I am really trying to focus and get some time to finish the new interval scheduling program, which I see as the most flexible program that can accommodate many different scheduling need. What has been bugging me is the issue that the newly added features require a lot of program memory space, and the small 32KB flash size of ATMEGA328 doesn’t leave me much to spare. Particularly, the webpages and javascripts are currently all stored in program memory space, and I’ve been playing around to find a way to offload them to somewhere else, such as the external EEPROM. Today, a solution finally came into my mind. While searching for ‘client side include’ (CSI), I realized that it is pretty simple to include, in an html file, a javascript that is stored on a remote server. For example, using:

< script src="http://rayshobby.net/javascripts/ps1.js >< /script >

allows me to include a large javascript file that exists on a remote server and thus does not have to be stored in the microcontroller’s program space. When you access a page on OpenSprinkler, the client (i.e. your browser) will retrieve the webpage automatically upon reading that line. Ah ha, a darn simple way to offload big java scripts from the microcontroller. Why didn’t I think about it before!

Of course the problem with this approach is that if the remote server is down, you can’t really do much. The probability of this happening is usually extremely small. But still, it is a good idea to put webpages related to the most essential functions on-board, while using the remotely stored javascripts for beautifying webpages etc. In any case, this provides a good way to make the precious program memory space available for adding new features.

Just to give you an idea of what’s happening, here are two snapshots of the new schedule webpages I am working on:

The idea is that you can define many ‘schedule items’, each of which consists of Time (which can be a weekly schedule, odd or even day schedule, or every N day schedule), selection of stations, start time, end time, interval, and duration (down to seconds). You can add as many such items as you want, subject to the EEPROM size. These pages are not looking beautiful yet, but with the trick mentioned above, they can potentially look much more fancy.

Something else I’ve been working on is reverse engineering RF signals sent from remote temperature and humidity sensors as well as wireless rain sensors. There are lots of these off-the-shelf remote sensing transmitters that you can buy at very competitive price in retail stores. These transmitters typically work in 434 MHz RF range. I’ve found a simple method to reverse engineer their RF signals, and I’ve successfully decoded data from a temperature and humidity sensor. Hopefully I will be able to figure out the rain sensor as well. It has been great fun, and I will devote a couple of posts soon to describe how I did it.

All right, so much for today!

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!

« Newer Posts - Older Posts »