Data Logging Shield RTC PCF8523 Stuck in Setup


I am working on a project with an Arduino Pro (5V, 16MHz, ATMega328P) and a Data Logging Shield (Overview | Adafruit Data Logger Shield | Adafruit Learning System).

I am trying to get my RTC set up so that I can print time stamps in Unix time. I am using the RTClib library (GitHub - adafruit/RTClib: A fork of Jeelab's fantastic RTC Arduino library) to run the RTC. I used the example given in the library for the PCF8523 to initialize my RTC. At first, it was working fine, but now it is not, and I am not sure why. It no longer prints any time stamps, and keeps getting stuck in the setup of the code. I have tried using both my code and the example, and they both run into the same issue.

I added some basic serial.print statements to check to see where it is getting hung up. Apparently, it's just getting stuck at the "if (! rtc.initialized())" part. I know that I have initialized it correctly because when it was making it through the set up, it was printing the correct time.

Occasionally I will get it to make it through the set up, but I don't know what I am doing differently to get it to run, and it doesn't seem consistent. When it is working, I can hit the reset button on the Arduino and it will always work perfectly again, but when I close the serial port and re-upload the same code without touching the Arduino, it will get stuck and be unable to make it through the set up, even though it was just working a second ago.

Basically, I am not sure if I am doing something wrong or if there is something wrong with my connections. I have a separate file that records data on an SD card using the same shield, and that data is recorded fine, so I am led to believe that it is not a connection issue.

Any help or suggestions would be greatly appreciated!

My Code:

#include <RTClib.h>

RTC_PCF8523 rtc;

void setup() {

  while(!Serial) {

  Serial.println("Initializing RTC");
  if(! rtc.begin()){
    Serial.println("Couldn't find RTC");

  // A test to debug
  // Check to make sure that RTC has been initialized
  if(! rtc.initialized()){
    Serial.println("RTC is NOT running!");
    //rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

  // A test to debug
  Serial.println("made it!");

void loop() {
  DateTime now =;

  //Calculate and print unix time


Mechanical problem.

Thank you for your response! Do you think that it is a problem with the connections, the shield, or the RTC itself? I would like to replace it but am not sure what to replace.

replace what?

it's a shield with everything built in

buy another shield if you think the one you have is faulty

connections, the shield, or the RTC itself?

It could be user abuse. Check that the shield is flat, parallel, and properly seated. The pins should be about 2.5mm from the host board. It might also be a matter of inadequate power. please don't tell us you are using a 9v PP3 battery. I'm not aware of any shields with a bad reputation, and I think you should assume it is kosher.

That may be it. I am very new to electronics so when I soldered the pins onto the shield I may have not done it evenly. The solders seem okay (they're all shiny and none are touching each other), but they definitely could be better.

Also, I am using a small FTDI chip (similar to this but made by a different company FTDI Friend + extras [v1.0] : ID 284 : $14.75 : Adafruit Industries, Unique & fun DIY electronics and kits) to connect from the Arduino Pro to a micro USB cable, which I am connecting to my laptop. No 9v PP3 battery as far as I'm concerned.

It just seems odd that all of my other programs with the shield + Arduino combo work fine but this one isn't. I will re-check the solders and maybe buy a new shield to re-solder.

Thank you for the guidance! :slightly_smiling_face:

It just seems odd that all of my other programs with the shield + Arduino combo work fine

I think you should put that down to good luck and little else, and buying a Uno to go along with the new shield would also be a rather good idea. I bet you don't have a good reason for combining a Uno shield with a Pro whatever, and this will also save you from fartarsing about with FTDI.