I'd like to use a RTC for accurate timestamping of pulses from a rain gauge that I am building. Has anyone come across a library that works with the ZUNO for this purpose?
The RTC I'm looking to use is a PCF8563.
Is there a Library available for using a Real Time Clock shield
-
- Posts: 26
- Joined: 07 Aug 2022 21:54
Re: Is there a Library available for using a Real Time Clock shield
It might be enough to use Clock command class and use internal timer. Clock has to be implemented in Z-Uno 2, but it is rather simple
-
- Posts: 26
- Joined: 07 Aug 2022 21:54
Re: Is there a Library available for using a Real Time Clock shield
Thanks for the reply and suggestion!
I would prefer to use a dedicated RTC module, because it will retain its settings and keep time even if there is a power interruption. I also believe that the RTC modules will be slightly more accurate, although for the purposes of this application, extreme accuracy is not required.
I would prefer to use a dedicated RTC module, because it will retain its settings and keep time even if there is a power interruption. I also believe that the RTC modules will be slightly more accurate, although for the purposes of this application, extreme accuracy is not required.
Re: Is there a Library available for using a Real Time Clock shield
PoltoS, there is a library for DS3231 & DS3232 called ZUNO_DallasRTC.
Isn't it possible to use ZUNO_DallasRTC to work with Z-Uno V2?
If not, what has to be done to make it work with Z-Uno v2?
Isn't it possible to use ZUNO_DallasRTC to work with Z-Uno V2?
If not, what has to be done to make it work with Z-Uno v2?
Re: Is there a Library available for using a Real Time Clock shield
At the first glance it looks compatible. We will check it, but you can also try on your sidee
Re: Is there a Library available for using a Real Time Clock shield
Thanks for answer.
I’m waiting for my rtc-order to arrive, after that that I’ll come back.
I’m waiting for my rtc-order to arrive, after that that I’ll come back.
Re: Is there a Library available for using a Real Time Clock shield
Hi, sorry for 3 month delay.
I bought and tried two DS3231 of different brands because there was this problem reading from RTC and
I first thought that there was something wrong with the first RTC.
I bought another but the problem remaines.
This is my program:
// ****************************************** TimeRTC_2_20240608131402 ***********************************************
#include <ZUNO_DS3232RTC.h>
#include <Time.h>
#define Serial Serial
// Arduino DS3232RTC Library
// https://github.com/JChristensen/DS3232RTC
//
// Example sketch illustrating Time library with Real Time Clock.
// This example is similar to the example provided with the Time Library.
// The #include statement has been changed to include the DS3232RTC library.
/*
******************** In ArduinoTypes.h *****************
struct tmElements_s {
byte Second;
byte Minute;
byte Hour;
byte Wday; // day of week, sunday is day 1
byte Day;
byte Month;
byte Year; // offset from 1970;
};
*/
DS3232RTC myRTC;
tmElements_t te, te_r;
time_t ts; // secs since 1900.
void setup()
{
Serial.begin(9600);
Serial.printf("\n\n****************************************** TimeRTC_2_20240608131402 ***********************************************\n\n");
te.Second = 30;
te.Minute = 32;
te.Hour = 13;
te.Wday = 6;
te.Day = 8;
te.Month = 6-1;
te.Year = 2024 -1900;
myRTC.write(&te);
}
void loop()
{
myRTC.read(&te_r);
disp();
delay(10000);
}
void disp(void){
Serial.printf("\n*************\n%04d-%02d-%02d %02d:%02d:%02d : Weekday = %d.\n", te_r.Year + 1900, te_r.Month + 1, te_r.Day, te_r.Hour, te_r.Minute, te_r.Second, te_r.Wday);
}
and this is the result.
****************************************** TimeRTC_2_20240608131402 ***********************************************
*************
2024-06-08 13:32:30 : Weekday = 6.
*************
2024-06-08 13:32:40 : Weekday = 6.
*************
2024-06-08 13:32:50 : Weekday = 6.
*************
2024-06-08 13:33:00 : Weekday = 6.
*************
2024-15-05 06:13:43 : Weekday = 0.
*************
2024-15-05 06:13:53 : Weekday = 0.
*************
2024-15-05 06:14:03 : Weekday = 0.
*************
1935-01-06 06:14:13 : Weekday = 4.
As you can see it works well until time changes at 13:33:00, after that the result is unpredictable
with month 15, weekday 0 and changes time to before world war 2.
This happens all the time, even if I change delay to one minute, 30 minutes or 1 hour, sooner or later the time reading is corrupt.
I have an Arduino Uno R3 too and when using the same RTC on Uno, with Uno:s library, it works very well
for weeks. As I see it never went wrong.
I don't know what to do, can you help?
I bought and tried two DS3231 of different brands because there was this problem reading from RTC and
I first thought that there was something wrong with the first RTC.
I bought another but the problem remaines.
This is my program:
// ****************************************** TimeRTC_2_20240608131402 ***********************************************
#include <ZUNO_DS3232RTC.h>
#include <Time.h>
#define Serial Serial
// Arduino DS3232RTC Library
// https://github.com/JChristensen/DS3232RTC
//
// Example sketch illustrating Time library with Real Time Clock.
// This example is similar to the example provided with the Time Library.
// The #include statement has been changed to include the DS3232RTC library.
/*
******************** In ArduinoTypes.h *****************
struct tmElements_s {
byte Second;
byte Minute;
byte Hour;
byte Wday; // day of week, sunday is day 1
byte Day;
byte Month;
byte Year; // offset from 1970;
};
*/
DS3232RTC myRTC;
tmElements_t te, te_r;
time_t ts; // secs since 1900.
void setup()
{
Serial.begin(9600);
Serial.printf("\n\n****************************************** TimeRTC_2_20240608131402 ***********************************************\n\n");
te.Second = 30;
te.Minute = 32;
te.Hour = 13;
te.Wday = 6;
te.Day = 8;
te.Month = 6-1;
te.Year = 2024 -1900;
myRTC.write(&te);
}
void loop()
{
myRTC.read(&te_r);
disp();
delay(10000);
}
void disp(void){
Serial.printf("\n*************\n%04d-%02d-%02d %02d:%02d:%02d : Weekday = %d.\n", te_r.Year + 1900, te_r.Month + 1, te_r.Day, te_r.Hour, te_r.Minute, te_r.Second, te_r.Wday);
}
and this is the result.
****************************************** TimeRTC_2_20240608131402 ***********************************************
*************
2024-06-08 13:32:30 : Weekday = 6.
*************
2024-06-08 13:32:40 : Weekday = 6.
*************
2024-06-08 13:32:50 : Weekday = 6.
*************
2024-06-08 13:33:00 : Weekday = 6.
*************
2024-15-05 06:13:43 : Weekday = 0.
*************
2024-15-05 06:13:53 : Weekday = 0.
*************
2024-15-05 06:14:03 : Weekday = 0.
*************
1935-01-06 06:14:13 : Weekday = 4.
As you can see it works well until time changes at 13:33:00, after that the result is unpredictable
with month 15, weekday 0 and changes time to before world war 2.
This happens all the time, even if I change delay to one minute, 30 minutes or 1 hour, sooner or later the time reading is corrupt.
I have an Arduino Uno R3 too and when using the same RTC on Uno, with Uno:s library, it works very well
for weeks. As I see it never went wrong.
I don't know what to do, can you help?
Re: Is there a Library available for using a Real Time Clock shield
Hello.
Does it always start to become distorted after “13:33:00” or can the time be different?
Does it always start to become distorted after “13:33:00” or can the time be different?
Re: Is there a Library available for using a Real Time Clock shield
Hi.
It can be any time, but, I think, it always start after a minute change.
It can be any time, but, I think, it always start after a minute change.
Re: Is there a Library available for using a Real Time Clock shield
Hi again, i'll add som more examples.
Different time setting are right just after setup.
****************************************** TimeRTC_2_20240608131402 ***********************************************
************
2024-07-17 12:40:30 : Weekday = 3.
*************
2024-07-17 12:40:40 : Weekday = 3.
*************
2024-07-17 12:40:50 : Weekday = 3.
*************
2024-07-17 12:41:00 : Weekday = 3.
*************
2024-15-06 03:12:51 : Weekday = 7.
*************
2024-15-06 03:13:01 : Weekday = 7.
*************
2024-15-06 03:13:11 : Weekday = 7.
*************
2024-15-06 14:06:17 : Weekday = 4.
*************
2024-15-06 14:06:27 : Weekday = 4.
***************************************** TimeRTC_2_20240608131402 ***********************************************
*************
2024-07-17 12:52:00 : Weekday = 3.
*************
2024-15-06 03:13:02 : Weekday = 7.
*************
2024-07-07 13:13:12 : Weekday = 3.
****************************************** TimeRTC_2_20240608131402 ***********************************************
*************
2024-07-17 18:50:05 : Weekday = 3.
*************
1948-11-17 18:50:15 : Weekday = 3.
*************
1948-11-17 18:50:25 : Weekday = 3.
*************
1948-11-17 18:50:35 : Weekday = 3.
*************
1948-11-17 18:50:45 : Weekday = 3.
*************
1948-11-17 18:50:56 : Weekday = 3.
*************
1948-11-17 18:51:06 : Weekday = 3.
*************
1981-11-17 18:51:16 : Weekday = 3.
***************************************** TimeRTC_2_20240608131402 ***********************************************
*************
2024-07-17 23:59:20 : Weekday = 3.
*************
2024-07-17 23:59:30 : Weekday = 3.
*************
2024-07-17 23:59:40 : Weekday = 3.
*************
2024-07-17 23:59:50 : Weekday = 3.
*************
2024-07-18 00:00:00 : Weekday = 4.
*************
2024-15-06 04:00:10 : Weekday = 0.
Different time setting are right just after setup.
****************************************** TimeRTC_2_20240608131402 ***********************************************
************
2024-07-17 12:40:30 : Weekday = 3.
*************
2024-07-17 12:40:40 : Weekday = 3.
*************
2024-07-17 12:40:50 : Weekday = 3.
*************
2024-07-17 12:41:00 : Weekday = 3.
*************
2024-15-06 03:12:51 : Weekday = 7.
*************
2024-15-06 03:13:01 : Weekday = 7.
*************
2024-15-06 03:13:11 : Weekday = 7.
*************
2024-15-06 14:06:17 : Weekday = 4.
*************
2024-15-06 14:06:27 : Weekday = 4.
***************************************** TimeRTC_2_20240608131402 ***********************************************
*************
2024-07-17 12:52:00 : Weekday = 3.
*************
2024-15-06 03:13:02 : Weekday = 7.
*************
2024-07-07 13:13:12 : Weekday = 3.
****************************************** TimeRTC_2_20240608131402 ***********************************************
*************
2024-07-17 18:50:05 : Weekday = 3.
*************
1948-11-17 18:50:15 : Weekday = 3.
*************
1948-11-17 18:50:25 : Weekday = 3.
*************
1948-11-17 18:50:35 : Weekday = 3.
*************
1948-11-17 18:50:45 : Weekday = 3.
*************
1948-11-17 18:50:56 : Weekday = 3.
*************
1948-11-17 18:51:06 : Weekday = 3.
*************
1981-11-17 18:51:16 : Weekday = 3.
***************************************** TimeRTC_2_20240608131402 ***********************************************
*************
2024-07-17 23:59:20 : Weekday = 3.
*************
2024-07-17 23:59:30 : Weekday = 3.
*************
2024-07-17 23:59:40 : Weekday = 3.
*************
2024-07-17 23:59:50 : Weekday = 3.
*************
2024-07-18 00:00:00 : Weekday = 4.
*************
2024-15-06 04:00:10 : Weekday = 0.