logging shield RTC not working

This has got to be something simple I am doing wrong. I am following the "Using the Real Time Clock" instructions on the Adafruit data logger shield page for setting the time. I uncommented the rtc.adjust line, which is supposed to get the time from the PC, but it continues to give the "RTC is not running!" error. Arduino UNO, Datalogging SD card shield with 8523 RTC. It runs the rtc.begin without error, so the library is likely ok.

Post your code and we can help

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

RTC_PCF8523 rtc;

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

void setup () {

  while (!Serial) {
    delay(1);  // for Leonardo/Micro/Zero
  }

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

  if (! rtc.initialized()) {
    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, 3, 13, 17, 50, 30));
    // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    
  }
}

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, 12 hours 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);
}

(never posted code before. I hope its ok.)
Gives the error "RTC is not running!"
This is the same code as on the logger shield tutorial.
thanks.

FYI.. rtc.begin() always returns TRUE even through the examples suggest you can determine if the RTC is present or not - you can't.

Try running the i2cbusscan sketch to verify you can see the RTC on the bus. I'm guessing you can't.

i2cBusScan.ino (771 Bytes)

It looks like nothing ding'ed. What does this mean? Is the shield perhaps not connected properly? It is soldered to the pins with no shorts, and is seated nicely on the Uno, and has the RTC battery installed. Is there an additional hardware connection I need to make?

I2CScanner ready!
starting scanning of I2C bus from 0 to 127...
addr: 0x0		addr: 0x1		addr: 0x2		addr: 0x3	
addr: 0x4		addr: 0x5		addr: 0x6		addr: 0x7	
addr: 0x8		addr: 0x9		addr: 0xA		addr: 0xB	
addr: 0xC		addr: 0xD		addr: 0xE		addr: 0xF	
addr: 0x10		addr: 0x11		addr: 0x12		addr: 0x13	
addr: 0x14		addr: 0x15		addr: 0x16		addr: 0x17	
addr: 0x18		addr: 0x19		addr: 0x1A		addr: 0x1B	
addr: 0x1C		addr: 0x1D		addr: 0x1E		addr: 0x1F	
addr: 0x20		addr: 0x21		addr: 0x22		addr: 0x23	
addr: 0x24		addr: 0x25		addr: 0x26		addr: 0x27	
addr: 0x28		addr: 0x29		addr: 0x2A		addr: 0x2B	
addr: 0x2C		addr: 0x2D		addr: 0x2E		addr: 0x2F	
addr: 0x30		addr: 0x31		addr: 0x32		addr: 0x33	
addr: 0x34		addr: 0x35		addr: 0x36		addr: 0x37	
addr: 0x38		addr: 0x39		addr: 0x3A		addr: 0x3B	
addr: 0x3C		addr: 0x3D		addr: 0x3E		addr: 0x3F	
addr: 0x40		addr: 0x41		addr: 0x42		addr: 0x43	
addr: 0x44		addr: 0x45		addr: 0x46		addr: 0x47	
addr: 0x48		addr: 0x49		addr: 0x4A		addr: 0x4B	
addr: 0x4C		addr: 0x4D		addr: 0x4E		addr: 0x4F	
addr: 0x50		addr: 0x51		addr: 0x52		addr: 0x53	
addr: 0x54		addr: 0x55		addr: 0x56		addr: 0x57	
addr: 0x58		addr: 0x59		addr: 0x5A		addr: 0x5B	
addr: 0x5C		addr: 0x5D		addr: 0x5E		addr: 0x5F	
addr: 0x60		addr: 0x61		addr: 0x62		addr: 0x63	
addr: 0x64		addr: 0x65		addr: 0x66		addr: 0x67	
addr: 0x68		addr: 0x69		addr: 0x6A		addr: 0x6B	
addr: 0x6C		addr: 0x6D		addr: 0x6E		addr: 0x6F	
addr: 0x70		addr: 0x71		addr: 0x72		addr: 0x73	
addr: 0x74		addr: 0x75		addr: 0x76		addr: 0x77	
addr: 0x78		addr: 0x79		addr: 0x7A		addr: 0x7B	
addr: 0x7C		addr: 0x7D		addr: 0x7E		addr: 0x7F	

done

Are you using a Rev B shield. They talk about the newer RevB not having SDA/SCL connected to A4/A5 which you need to for an UNO. You have to short a couple of jumpers. Have you done this?

The text says on the UNO the SDA is already tied to A4, and the SCL is A5:
"On an UNO, note that Digital #13 is the same as ICSP SCK, #12 is ICSP MISO, #11 is ICSP MOSI, SDA is tied to A4 and SCL is A5. However, that is only true on the UNO! "

But I soldered the jumper the SDA and SCL jumpers anyway to give it a try. Now the example I posted earleir doesnt print out anything. (I ran some other programs that print and they worked, so at least its not totally dead)

I'm confused.

jgolden:
The text says on the UNO the SDA is already tied to A4, and the SCL is A5:
"On an UNO, note that Digital #13 is the same as ICSP SCK, #12 is ICSP MISO, #11 is ICSP MOSI, SDA is tied to A4 and SCL is A5. However, that is only true on the UNO! "

But I soldered the jumper the SDA and SCL jumpers anyway to give it a try. Now the example I posted earleir doesnt print out anything. (I ran some other programs that print and they worked, so at least its not totally dead)

I'm confused.

I believe they are making note that the UNO board itself uses A4/A5 for SCL/SDA, not that those are connected to the shield that way. That is what the jumpers are for.

Your initial output above shows a device present at every address which may mean that SDA is shorted or something (i2c acknowledges communication by pulling SDA low.)

But now you see nothing? What "other programs" did you run? Were they communicating over i2c?

The output from the i2cbus scan is now:

I2CScanner ready!
starting scanning of I2C bus from 0 to 127...
addr: 0x0

When I run the pcf8523 program (for the RTC) I now get nothing printed.

I ran a small program that prints out random numbers ( loops Serial.println(random(30)); ), just to make sure the Arduino is able to run a program and print to the screen. I'm not smart enough to know if that uses the i2c.

address 0 is a special address. You should be seeing address 0x68 (decimal 104).

Printing to the serial monitor has nothing to do with the i2c bus...

I'm afraid you have some sort of hardware issue...

It seems you are correct! Hardware.

I checked the pins I soldered onto the logger board and there are too few of them. I put 8 pins instead of 10 (leaving out the SCL pin). So that is now working. However I have a 2nd logger board that gives a "cant open Com11" error. When I install the shield it seems to get rid of the UNO's com port. Wierd. Any thoughts?