SMILEY’S WORKSHOP ☺
■ FIGURE 15. DS1307-RTC on breadboard
get the power and ground correct. Figures 6 and 7
show the DS1307 wired up on a breadboard for use
with the Arduino. It also has the LCDNAV wired up
(perhaps for a breadboard alarm clock that we might
see in a later Workshop).
■ FIGURE 13. Arduino DS1307 printed circuit board.
■ FIGURE 14. DS1307 RTC PCB with components.
Bill of Materials
Table 1 lists the parts you can get from www.mouser.
com. (Or, as mentioned before, you can check the
Nuts & Volts Webstore where you can get these parts
and a PCB to mount them on.)
Using the DS1307 With the Arduino
There is an excellent library for the Arduino at
www.arduino.cc/playground/Code/Time that lets you
use a DS1307. Follow the Arduino directions for including
a library. Then, click on the library and the DS1307
examples as shown in Figure 8. The files shown in
Figure 9 calculate the seconds from the Unix Epoch
which began 1/1/1970, convert that to days and then to
now (today’s date/time) plus seven days and 30 seconds
as shown in Figure 10.
There is certainly nothing wrong with purchasing all
the parts and then building this circuit on a breadboard as
discussed above. It is easier and more reliable, however, to
build it on a printed circuit board. Figure 11 shows the
schematic; Figure 12 shows the components. Figure 13
shows the PCB; Figure 14 shows the PCB with the parts
mounted; and Figure 15 shows it on a breadboard
hooked up to an Arduino. The DS1307 uses the I2C bus
where pin 6 goes to SDA and pin 7 goes to SCL. On the
Arduino, we connect the SDA to the analog pin 4 and
SCL to analog pin 5. These Arduino pins are, of course,
not used in the analog mode, but are set up in software
for the I2C bus. You can use the same software as
discussed above for the breadboard version of the design.
So, now we have a tool to provide a real time clock
on a breadboard. We see that we can use this tool with
an open source Arduino library. My goal in building the
breadboard RTC was to provide a design that can be
July 2012 61