DS1307 not incrementing time

I just got a couple DS1307 RTCs, and I haven’t had any success to get them to work with a very basic test circuit and code. I have tried running 3 or 4 different example codes that I found in the forums, and they all give the same result of just continusouly printing 0’s to the serial monitor (ex 0:00:00 0 0 2000). Also, since I have two DS1307’s, I have tried swapping chips with the same result. I have also tried pull-up resistors on pins 5 and 6 of the RTC and adding a 3V coin cell to Vbat with no success. Not really sure what else to try…

My circuit.

One of the programs I tried.

#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h> // written by  mattt on the Arduino forum and modified by D. Sjunnesson

void setup()

  RTC.set(DS1307_SEC,1);        //set the seconds
  RTC.set(DS1307_MIN,23);     //set the minutes
  RTC.set(DS1307_HR,12);       //set the hours
  RTC.set(DS1307_DOW,4);       //set the day of the week
  RTC.set(DS1307_DATE,5);       //set the date
  RTC.set(DS1307_MTH,3);        //set the month
  RTC.set(DS1307_YR,9);         //set the year


void loop()

  Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
  Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
  Serial.print(RTC.get(DS1307_SEC,false));//read seconds
  Serial.print("      ");                 // some space for a more happy life
  Serial.print(RTC.get(DS1307_DATE,false));//read date
  Serial.print(RTC.get(DS1307_MTH,false));//read month
  Serial.print(RTC.get(DS1307_YR,false)); //read year 



The code looks fine. You say your wires go to pins 4 and 5. You did connect them to the Analog Pins and not the Digital Pins didn’t you?

Assuming that the I2C lines are going to the correct analogue pins the other problem could be that the crystal is not going. Look at it on a scope to see.

You might have to put some 22pF capacitors from each end of the crystal to ground, in order to get it going.

Doh, I didn’t realize that it went to the analog inputs… Thanks guys, I knew it had to be something stupid.


We've all done it.