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.
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 ...
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.
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.
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.