How to troubleshoot real-time clock Pcf8563 ?

Hi,
a couple of days ago I got my Pcf8563 based RTC module for my Arduino project. I am using Joe Robertsons library and I am trying to set the clock. Unfortunately I can read the clock but not set it. No matter what I try the serial monitor always outputs

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

I assume that is the factory “preset” and the clock is just not set at all.

This is the exact sketch I am using - as you can see I just replaced the given dates with the current ones. It did not work with the original ones either:

/* Demonstration of Rtc_Pcf8563 Set Time. 
 * Set the clock to a time then loop over reading time and 
 * output the time and date to the serial console.
 *
 * I used a RBBB with Arduino IDE, the pins are mapped a 
 * bit differently. Change for your hw
 * SCK - A5, SDA - A4, INT - D3/INT1
 *
 * After loading and starting the sketch, use the serial monitor
 * to see the clock output.
 * 
 * setup:  see Pcf8563 data sheet.
 *         1x 10Kohm pullup on Pin3 INT
 *         No pullups on Pin5 or Pin6 (I2C internals used)
 *         1x 0.1pf on power
 *         1x 32khz chrystal
 *         
 * Joe Robertson, jmr
 * orbitalair@bellsouth.net
 */ 
#include <Wire.h>
#include <Rtc_Pcf8563.h>

//init the real time clock
Rtc_Pcf8563 rtc;

void setup()
{
  Serial.begin(9600);
  //clear out the registers
  rtc.initClock();
  //set a time to start with.
  //day, weekday, month, century(1=1900, 0=2000), year(0-99)
  rtc.setDate(16, 3, 8, 0, 18);
  //hr, min, sec
  rtc.setTime(16, 52, 0);
}

void loop()
{
  //both format functions call the internal getTime() so that the 
  //formatted strings are at the current time/date.
  Serial.print(rtc.formatTime());
  Serial.print("\r\n");
  Serial.print(rtc.formatDate());
  Serial.print("\r\n");
  delay(1000);
}

I quadruple-checked my connections and am sure it is not a connection error.

I also tried to run the function test included in the library. That did not help either.

What could I do next to find out what’s wrong?

Unfortunately I can read the clock but not set it. No matter what I try the serial monitor always outputs

I doubt that you can read from the chip. It would always return an existing time but your output is way from existing.

I quadruple-checked my connections and am sure it is not a connection error.

In this case post a wiring diagram.

What could I do next to find out what's wrong?

Run an I2C scanner to check your connections. If the I2C scanner doesn't find the chip, the connection is not correct.

Thank you for your input and pointing me to the I2C scanner. The chip is indeed not found.

There is not much of a diagram I could post. As advised in the documentation I wired

VCC to 5V on Arduino
GND to Ground on Arduino
SDA to Pin 4 on Arduino
SCL to Pin 5 on Arduino

Nothing else. The Arduino board is working fine with other sketches and the odd component or five. Just this RTC is not doing what I expected. I guess I'll have to get out the meters and follow the current ...

fertchen80:
I wired

VCC to 5V on Arduino
GND to Ground on Arduino
SDA to Pin 4 on Arduino
SCL to Pin 5 on Arduino

SDA is on A4 and SCL on A5 on the ATmega328 Arduinos such as UNO, Pro Mini etc

Pin 4 and Pin 5 that you say you are using are not the correct pins.

srnet:
SDA is on A4 and SCL on A5 on the ATmega328 Arduinos such as UNO, Pro Mini etc

This is on Arduino UNO. Was that not clear?

srnet:
Pin 4 and Pin 5 that you say you are using are not the correct pins.

I am afraid I do not understand. In you just confirmed that Pin 4 and Pin 5 are supposed to be connected to SDA and SCL. If I am misreading or you mistyped, please let me know the correct Pin numbers. These are the one I am using according to the official library as stated above.

This is on Arduino UNO. Was that not clear?

Where did you say it was a UNO ?

I am afraid I do not understand. In you just confirmed that Pin 4 and Pin 5 are supposed to be connected to SDA and SCL. If I am misreading or you mistyped, please let me know the correct Pin numbers. These are the one I am using according to the official library as stated above.

I said nothing of the sort, read what I said again more carefully.

Then take a look at the UNO or a pinout diagram, you will see one set of pins labeled 0 to 13 and another labeled A0 to A5.

srnet:
Where did you say it was a UNO ?
. . .

I agree with this part.

. . .
I said nothing of the sort, read what I said again more carefully.

Then take a look at the UNO or a pinout diagram, you will see one set of pins labeled 0 to 13 and another labeled A0 to A5.

I can't figure out what you are getting at here. Perhaps you can restate what you think is the problem.

Don

OP has said very clearly they connected;

SDA to Pin 4 on Arduino
SCL to Pin 5 on Arduino

And they seem to assume;

Pin 4 is the same as Pin A4 ?
Pin 5 is the same as Pin A5 ?

srnet:
And they seem to assume;

Pin 4 is the same as Pin A4 ?
Pin 5 is the same as Pin A5 ?

Almost. I was focused on the line of pins numbered 0-13 and the A-pins completely slipped from my awareness. That is the reason for me missing the 'A' part in theses posts several times. The fact that I did so seems to be some kind of major faux pas as the tension here is palpable. I am very sorry if I upset you and that I am not as experienced as you are.

OK - now I see what you were saying.

I guess I would have worded things differently such as: You are using pins 4 and 5 when you should be using pins A4 and A5.

Don

fertchen80:
I was focused on the line of pins numbered 0-13 and the A-pins completely slipped from my awareness.

If you look at your UNO PCB, the labelling should be clear.

If your not experienced in this area, then be very cautious when making assumptions or letting things slip from your awareness.

Maybe there is actually a good reason for a pin being described as 'A5' not being the same as '5'.

srnet:
If your not experienced in this area, then be very cautious when making assumptions or letting things slip from your awareness.

Thank you so much for the advice. From now on I will be very cautious when consciously deciding what to let slip from my awareness.

srnet:
Maybe there is actually a good reason for a pin being described as ‘A5’ not being the same as ‘5’.

Do you really think so?

Thank you. It is good to know there will always be someone who never overlooks anything and never ever makes a mistake whom I can ask for advice.