Issue with a PCF8563 RTC sensor connected to an Arduino Uno

I am new to this forum. some days back i started using PCF8563 RTC sensor with Arduino uno and these are the components and schematics:



and after uploading this code:

#include <Wire.h>
#include <Rtc_Pcf8563.h>

//init the real-time clock
Rtc_Pcf8563 rtc;

void setup() {
  Serial.begin(9600);
  Wire.begin();

  //clear out all the registers
  rtc.initClock();
  //set a time to start with.
  //day, weekday, month, century, year
  rtc.setDate(7, 5, 10, 20, 23);
  //hr, min, sec
  rtc.setTime(16, 20, 0);
}

void loop() {

  Serial.print("Time:");
  //Serial.print(rtc.formatTime(RTCC_TIME_HM));
  Serial.print(rtc.formatTime());


  Serial.print("\t Date:");
  //Serial.println(rtc.formatDate(RTCC_DATE_ASIA));
  Serial.println(rtc.formatDate());


  delay(1000);
}

i was getting good response at the serial monitor. presently, i tried repeating what i did before and connected the rtc sensor back to the Arduino only for me to check the serial monitor and i started getting this:

Time:45:85:85	 Date:25/45/19@5
Time:45:85:85	 Date:25/45/19@5
Time:45:85:85	 Date:25/45/19@5
Time:45:85:85	 Date:25/45/19@5
Time:45:85:85	 Date:25/45/19@5
Time:45:85:85	 Date:25/45/19@5

and i am just confuse because even after removing removing the sensor, i still get the same readings at the monitor. how do i correct this? and where is the problem from?

I am not familiar with your library so how do you set the I2C address for the I2C. Also run the I2C scanner for a bit and see what you get, it should be solid one address, possibly 0x68.

i just did and i am not getting any address and the only thing that i am not sure of is the connecting pins attached to rtc sensor, they are not soldered but i have use it like that before now. And I don't know why i am getting a time and date dsiplay on my serial monitor without the rtc sensor connected, is it possible that it is a default for the code?

Assuming the scanner code is good it is a hardware problem. First thing I do not see any pull up resistors, one each for SCL and SDA each pulled up to +5V. Many suggest 10K, that is borderline as is using the internal pull ups on the pins which can be as high as 50K. If you say they are on the clock module please send a link to a schematic of the exact module you have, there are several similar modules available. If you add the pull up resistors and there are some on the clock module no damage done. The specification requires 1mA minimum on the pull up resistors.

Once the pull up resistor problem is solved run the scanner again, if it still gives you nothing reverse the SCL and SDA lines, at that point the scanner should work, if not something is probably broken. You need to try another UNO or clock module to determine which has failed.

This is the link:
https://dtsheet.com/doc/213313/philips-pcf8563t-f4.

i am not that knowledgeable in what was written but i could say that they did indicates the need to use a pull up resistor. i may be wrong, please if you can, enlighten me. below is my I2C scanning code, please help me check if did something wrong:

#include <Wire.h>

void setup() {
  Wire.begin();
  Serial.begin(9600);
  while (!Serial);

  Serial.println("\nI2C Scanner");
}

void loop() {
  byte error, address;
  int deviceCount = 0;

  Serial.println("Scanning...");

  for (address = 1; address < 127; address++) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address < 16) {
        Serial.print("0");
      }
      Serial.println(address, HEX);
      deviceCount++;
    } else if (error == 4) {
      Serial.print("Unknown error at address 0x");
      if (address < 16) {
        Serial.print("0");
      }
      Serial.println(address, HEX);
    }
  }

  if (deviceCount == 0) {
    Serial.println("No I2C devices found.");
  } else {
    Serial.println("Done.");
  }

  delay(5000); // Wait for 5 seconds before scanning again
}

It appears they told you that, I suggested the same thing without knowing what they said, do you think they may make a difference?

The scanner checks each address to determine if there is an active device at that address. You had one device and got one response, If you had three devices at different addresses you would get three responses. It appears your scanner is working correctly as it did not report anything when you removed it.

Guess what it does not see it when it is connected so what could be wrong.

  1. The logic levels are wrong because of a lack of pull up
  2. The device is bad.
  3. the device is mis wired.
    This is assuming all of the grounds are connected.
    The next step since I cannot examine your project is to post an annotated schematic showing exactly how you wired it, include all connections, power, ground, and power sources. Also some clear photos showing how it is assembled.

I can't really tell but i was able to make it work. I tried using a 10k pull up and still could not get a reading so i check and saw a similar problem in this forum that suggested soldering the terminal pins on the rtc sensor which i did and without connecting any pull up resistor, i was able to get a read from the sensor. I want to say i am grateful for your suggestions as they gave me more insight on topics that were confusing.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.