In this example we will experiment with a DS1307 breakout, a keypad/LCD shield and an Arduino. We will create a simple clock example.
The DS1307 real-time clock is a low-power, full binary-coded decimal clock/calendar. Address and data are transferred over the I²C bus.The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The DS1307 has a built-in power-sense circuit that detects power failures and automatically switches to the backup supply, this backup supply is usually a lithium ion battery.
Here is a picture of the setup we are using, you can see the DS1307 breakout connected to the LCD and keypad shield, in this example you can see the time displayed on the LCD.
Here is how you wire up the DS1307 to your Arduino
VCC and GND connect to 5v and GND
SCL connects to A5
SDA connects to A4
You will need to download and copy the RTCLib into your ARduino libraries folder
// Connections: Sainsmart LCD/Keypad shield
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
//setup the LCD
//debug the rtc
if (! rtc.isrunning())
//Serial.println(“RTC is NOT running!”);
// following line sets the RTC to the date & time this sketch was compiled
DateTime now = rtc.now();