Homemade RTC (DS1307) not displaying data

I am building a RTC based on Adafruit’s design. It uses a DS1307 with two 2.2k pull-up resistors on the SDA/SCL lines.

I wired everything as in the schematic below, with pin 5/SDA connected to A4 and pin 6/SCL connected to A5.

I don’t have a coin cell holder so I tried grounding pin 3, giving it it’s own 3V, and even connecting it to its own coin cell.

The chip has 5V and ground. There is a 32.768 crystal installed.

Yet when I run the ds1307 example code nothing appears in the serial monitor. I’ve double, even triple checked the baud rate, changed the baud rate in code, everything. Nothing will show up. I don’t have another chip or crystal to try unfortunately.

I did take a look at the code from this site. It runs but only when I remove the resistor going to pin A5. It also just displays the same number over and over again before quitting.

I have no idea what’s going on.

Adafruit code:

// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include "RTClib.h"

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {
  while (!Serial); // for Leonardo/Micro/Zero

  Serial.begin(9600);
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
}

void loop () {
    DateTime now = rtc.now();

    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(" (");
    Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
    Serial.print(") ");
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();

    Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");

    // calculate a date which is 7 days and 30 seconds into the future
    DateTime future (now + TimeSpan(7,12,30,6));

    Serial.print(" now + 7d + 30s: ");
    Serial.print(future.year(), DEC);
    Serial.print('/');
    Serial.print(future.month(), DEC);
    Serial.print('/');
    Serial.print(future.day(), DEC);
    Serial.print(' ');
    Serial.print(future.hour(), DEC);
    Serial.print(':');
    Serial.print(future.minute(), DEC);
    Serial.print(':');
    Serial.print(future.second(), DEC);
    Serial.println();

    Serial.println();
    delay(3000);
}

I wired everything as in the schematic below, with pin 5/SDA connected to A4 and pin 6/SCL connected to A5.

Does that mean you're using an UNO?

I am building a RTC based on Adafruit's design. It uses a DS1307 with two 2.2k pull-up resistors on the SDA/SCL lines.

Do you have long wires? Why did you choose the 2k2 pull-ups?

I don't have a coin cell holder so I tried grounding pin 3, giving it it's own 3V, and even connecting it to its own coin cell.

Grounding the pin is not a good idea as you won't be able to communicate with the chip. Is the mentioned 3V an exact 3V or more 3.3V or even more? The higher the voltage on the Vbat pin the higher voltage you need on Vcc to activate the I2C interface.

Post a complete wiring diagram (may be hand-drawn)!

Sorry I disappeared for a few days. Yes, I am using an Uno and the length of my wires are just from a breadboard next to my Uno, so maybe 10cm or less? I've seen designs use everything from 1.6k, 2.2k, and even 10k pull-up resistors. I figure if I copy Adafruit's schematic from their breakout kit, it ought to work.

I sourced a "3V" coin cell, however I didn't have my multimeter on hand. I just checked today, and despite passing the tongue test, it was less than a volt. I made a simple voltage divider using the 3.3v pin, ran the I2C scanner, and problem solved!

Thank you very much!

Update: it’s broken again. I can run the Adafruit code, and I even added an extra ‘if’ above the line:

  if (rtc.isrunning())
  {
    Serial.println("RTC IS running!");
  }
  
  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    //rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    //rtc.adjust(DateTime(2019, 8, 8, 19, 0, 0));
  }

but the second I power off and on the board again, the serial monitor says it’s not running. No matter how many times I recompile or reset the board the thing won’t talk to the Uno. If I go over to that example code I linked in my first post, upload and run it (which runs fine), then reupload the Adafruit code, it magically works again. It’s almost as if there’s some stuck buffer that gets cleared by the other code.

Is this related to the 3v supply turning off too? That would be problematic if the coin cell ever died or I needed to take it out for some reason.

Schematic for those wondering.

Is this related to the 3v supply turning off too? That would be problematic if the coin cell ever died or I needed to take it out for some reason.

Yes, if not powered by Vcc there needs to be 3.0v at Vbat or else the oscillator stops and the not running flag is set. When running on Vcc, a battery should be installed in the holder.