DS1307 RTC begin() method never gets called

I'm not sure if this is the right area for this topic, if not can the mods please move it.

I am using a DS1307 breakout as part of a project where I want to write the time and date to a Nokia 3310 LCD. The LCD works as expected, but if I remove the RTC breakout from the project the (! begin()) method never gets called. Instead it calls the (! isrunning()) method.

Here is the code I am using:

    #include <Adafruit_GFX.h>
    #include <Adafruit_PCD8544.h>
    #include "RTClib.h"
    #include <Wire.h>

    #define BACKLIGHT_PIN 7

    RTC_DS1307 rtc;
    Adafruit_PCD8544 display = Adafruit_PCD8544(5, 4, 3); //Download the latest Adafruit Library in order to use this constructor
    int contrast = 35;
    /*************************************************************************/

    void setup() {
      Serial.begin(115200);
      display.begin();
      display.clearDisplay();

      if (! rtc.begin()) {                                          // Does not detect missing RTC
        Serial.println(F("Couldn't find RTC"));
        display.clearDisplay();
        display.setTextSize(2);
        display.setCursor(5, 0);
        display.print("RTC");
        display.setCursor(5, 25);
        display.print("MISSING");
        display.display();

        while (1);
      }
      if (! rtc.isrunning()) {                                            // missing RTC is detected here instead!
        Serial.println(F("RTC is NOT running!"));
        Serial.println(F("Starting RTC now..."));
        display.clearDisplay();
        display.setTextSize(2);
        display.setCursor(5, 0);
        display.print("RTC");
        display.setCursor(5, 25);
        display.print("FAIL");
        display.display();
        // following line sets the RTC to the date & time this sketch was compiled
        //rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
      }
    }
    /*********************************************************************************/

    void loop() {
      // put your main code here, to run repeatedly:
    }

    void setContrast()  {
      display.setContrast(contrast);
      display.display();
    }

The RTC library being used is the Jeelabs one.
It is too big to post here, but please see the link above.

That library has this code:

boolean RTC_DS1307::begin(void) {
  Wire.begin();
  return true;
}

That returns true whether there's a DS1307 present or not so the next thing your code does is call isrunning.

Pete

Because I have other I2C devices on the bus, would I be correct to say that boolean RTC_DS1307::begin(void) would return true, since it would detect those even if the RTC is missing?

It has nothing to do with any other device on the bus. As long as Wire.begin() doesn't hang the processor (it doesn't look like it can), that function returns true no matter what is on the bus. In other words, even if there was nothing on the bus at all, rtc.begin() will indicate that a DS1307 is present.
On the other hand, rtc.isrunning() needs to have a DS1307 present for it to work correctly.

Pete

Ah, ok.
Thank you for your help, its greatly appreciated!