10-04-2017, 08:07 PM
ds1307 pcb
Although ready-made real-time clock (RTC) modules for microcontroller projects are available in every online shop, an inspired electronics hobbyist would rather put together something from a few components that happen to be lying around.
ds1307 ic Now a days, most microcontroller projects those which log or track data information often require current time and date information to be stored along with the accumulated data. A Real Time Clock (RTC) chip such as DS1307 with a suitable back-up battery can be used to supply the required information. The programming process of the RTC chip (in software) is also very simple and is supported in the majority of programming environments.
Here is the circuit diagram of a compact RTC module, based on the popular RTC IC DS1307, for your everyday microcontroller projects. The DS1307 serial real-time clock (RTC) is a lowpower, full binarycoded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C, bidirectional bus. The 24-hour/12-hour format clock/calendar provides seconds, minutes, hours, day, date, month, and year information, including corrections for leap year.
Parts List
DS1307 RTC chip 1
32.768 Khz (12.5 pF) generic quartz watch crystal 1
100nF Ceramic Capacitor 1
10K w Resistor 2
12mm 3V Lithium Coin Cell (CR2032) 1
12mm Coin Cell Holder 1
5-Pin Male Header 1
Circuit Board 1
DS1307 is a low cost, easy to handle, real-time clock chip works for years on a very small coin cell. DS1307 has a built-in power-sense circuit that detects power failures and automatically switches to the backup supply. Timekeeping operation continues while the part operates from the backup supply. You must have the 3V coin cell (lithium battery) installed for the RTC to work. In case of no coin cell,the battery pin (VBAT) should be pulled to low. Also note that negative undershoots below -0.3V while the part is in battery-backed mode may cause loss of data.
The last months at Bitraf has been quite hectic in terms of workshops & activities. First there was a soldering workshop that I helped put on, then a PCB design workshop and that was followed by a PCB etching workshop. I also organized our third 3D Printer Meetup there. Peter, Trygve and Carl at the hackerspace has now gotten my dad's old Roland CNC to drill all the required holes in a PCB based on the Eagle files, so it's really possible to make nice things at Bitraf these days.
When an Arduino looses power, it's clock will always start in 1970 when it gets power again. For a client project I'm working on, I needed the correct time after a power outage. It was easy to find several RTC's online and they all cost something between $5 and $10. My problem was that getting it fast would be expensive and I happened to have the most used IC for this purpose. The DS1307 used in most of these modules is about a dollar each and the remaining components are not much either. Here's the Bill Of Materials along with links to where I bought them:
1 x DS1307
1 x 32.768 Crystal
3 x 10k resistors
1 x 104 capacitor (0.1 uF)
1 x 2032 battery holder
2 x 6-header pins
All together this is about $2 in parts, even for a very modest volume. Not shabby and I highly recommend both TaydaElectronics (Thailand) and Spiratronics (UK). Both are great shops that ship quickly to places in Europe and I use them a lot in addition to ebay.co.uk.
I looked online, but couldn't find something that others had made that was "free to use" and I had an idea: why not make it plug straight into one of the header rows on the Arduino? That way it would be real plug-and-play since both power and the analog pins used for i2c are on the same side. Above you can see how this turned out - it plugs right into the Arduino Ethernet shield.
I looked up the reference design and looked at how others had done it before and then made a first go in Eagle. After a couple fails (I forgot to "fill" with ratsnest + had counted the pins incorrectly) I got a couple nice looking PCB's.
The etching went really well and with all the helpful people at Bitraf, it's not hard to get this right. I drilled this one manually, but I'll definitely use the Roland CNC as soon as we have a good way to cut consistent PCB sizes. Here's how it looked after cleaning with Acetone:
I didn't have the required clock crystals, but I got these from Spiratronics in just 3 days. Today I soldered it up and plugged it in. Guess what - it didn't work.. I looked over the PCB with a magnifier glass and cleaned up some excess solder along the traces and it still didn't work. Bummer. I went online and looked at how Adafruit did theirs and then it struck me - I had put the IC on the wrong side of the PCB.
After doing this, it worked like a charm! I used the Adafruit 1307 library and it works just as I hoped. I'll definitely make a couple more of these for other projects and so can you! Below you can find the Eagle schematic + board and here's the final stencil to use for the etching.