OpenSprinkler v2.1u Semi-Assembled DIY Kit Available Now!

Great news, OpenSprinkler v2.1u semi-assembled DIY kit has now been officially released and available immediately for purchase at the Rayshobby Shop! This version marks a major upgrade from the previous DIY kit v1.42u. With ATmega644 MCU, microSD card slot, and injection-molded enclosure, it not only brings the DIY kit up to speed with the fully assembled v2.0s, but it actually strives to be a little better (hence the migration on the version number) 🙂

In particular, it adds a mini-relay for general purpose switching (similar to the one on OpenSprinkler Beagle), changed the 24VAC terminal to an orange colored one with different pin spacing, and increased MCU frequency from 8MHz to 12Mhz. It also uses a USBasp bootloader built-in on the ATmega644 MCU for firmware flashing (while all previous versions use a separate ATtiny45 chip). The USBasp bootloader significantly improves the firmware upload speed, and is therefore very helpful if you are making frequent changes to the firmware. These changes are all described in the prototype sneakpeak preview post. Finally, the MCU is pre-loaded with the latest firmware 2.0.3 with several new features compared to the previous firmwares.

osdiy_headerIMG_3758

Another notable change is that v2.1u is the first semi-assembled DIY kit which comes with a partially assembled circuit board with through-hole components. I’ve designed it this way to help reduce the amount of soldering you have to do, while still let you enjoy the process of building, assembling, testing, and hacking the circuit. It’s a first-time experiment, so I will keep my fingers crossed.

In any case, if you’ve been waiting for OpenSprinkler DIY kits, go grab one quickly before it’s gone; if you already own an OpenSprinkler or have heard of OpenSprinkler one way or another, I would appreciate if you can help me spread the word. Thanks!

IMG_3762

Modified Arduino DS1307RTC library that also works for MCP7940N

DS1307 is an old and classic real-time clock (RTC) chip that has been used in many electronic circuits. There are also many libraries written for DS1307, notably this Arduino Time library which includes a DS1307RTC class. Given its age and popularity, it’s surprising that the chip is not cheap: even at volume pricing, it usually costs around $2 each. Even a microcontroller like ATtiny45 costs only about about 60 cents. How complicated can an RTC chip be compared to a microcontroller!

Recently I came across Microchip’s MCP7940N, which is less expensive and is pretty much a drop-in replacement of DS1307. At a quantity of 100, it costs 65 cents each, which is about a third of the price of DS1307. To be fair, there are even cheaper options, but those often do not have battery backup support, which would not be desirable.

IMG_3832

Microchip has published a DS1307 to MCP7940N migration document which thoroughly explained the differences between the two. To begin, Microchip recommends adding a few extra elements, such as load capacitors for 32.768kHz crystal, and protection circuitry for the backup battery. If you are not so concerned with this level of reliability, you can leave out these elements and hence it will be truly a drop-in replacement.

Next, there are a few software changes we have to make, mainly three:

  • I2C address: MCP7940N uses address 1101111 while DS1307 uses 1101000.
  • Clock enable: MCP7940N uses active high while DS1307 uses active low.
  • Battery backup: MCP7940N disables it on startup while DS1307 always enables it.

These changes are fairly easy to make. So I modified the DS1307RTC library to accommodate both. The library can automatically detect which RTC chip you have. Using the modified library, you need to first run RTC.detect() to detect whether an RTC chip is installed and which one it is. The detect() function returns 0 if either DS1307 or MCP7940N is detected, and a non-zero value if an error has occurred. The rest is the same as before.

This library can replace the one included in Arduino’s Time library. Note that it also works for DS3231, which is compatible with DS1307 but with a built-in temperature compensated crystal.

That’s all. Next time you need an RTC, perhaps you will consider using MCP7940N as an inexpensive alternative to DS1307 🙂