Ported: JChristensen/DS3232RTC

Kenjutsu
Mon Feb 15, 2016 1:50 pm
[2018-07-21 —UPDATE—] [ Updated to the latest version of DS3232RTC library of JChristensen]

Hello everyone,

I ported the DS3232RTC library of JChristensen and tested it with a DS3231 AT24C32 IIC module precision Real time clock module memory module Arduino. I only tested the SetSerial.ino example program.

The port can be found here: https://github.com/KenjutsuGH/DS3232RTC.git


RogerClark
Tue Feb 16, 2016 9:48 am
Thanks

I’m not sure if you are aware but the STM32 has its own internal real time clock which uses an external 32kHz crystal, I think @ahull is the expert in this, and some boards need modification to run from batteries in low power mode.

But its still worth pointing out this built in feature


Pito
Sat May 07, 2016 3:01 pm
Hi, I’ve taken this lib (I need a timestamp for the sdfat)
The port can be found here: https://github.com/KenjutsuGH/DS3232RTC.git
but I cannot get it compiled (Maple Mini, 1.6.5), for example
#include <DS3232RTC.h>
#include <Time.h>
#include <Wire.h>

RogerClark
Sat May 07, 2016 9:45 pm
post the errors

Pito
Sun May 08, 2016 6:58 am
In file included from C:\Users\pito\MyCode\Arduino\libraries\DS3232/DS3232RTC.h:40:0,
from STM_RDWR_1.ino:8:
C:\Users\pito\MyCode\Arduino\libraries\Time/Time.h:16:23: error: conflicting declaration 'typedef long unsigned int time_t'
typedef unsigned long time_t;
^
In file included from c:\users\pito\appdata\roaming\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\stdio.h:47:0,
from C:\Users\pito\MyCode\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/wirish.h:42,
from C:\Users\pito\MyCode\Arduino\hardware\Arduino_STM32\STM32F1\cores\maple/Arduino.h:30,
from STM_RDWR_1.ino:6:
c:\users\pito\appdata\roaming\arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\sys\types.h:122:18: error: 'time_t' has a previous declaration as 'typedef long int time_t'
typedef _TIME_T_ time_t;
^
Multiple libraries were found for "Wire.h"
Used: C:\Users\pito\MyCode\Arduino\libraries\Wire
Not used: C:\Users\pito\MyCode\Arduino\hardware\Arduino_STM32\STM32F1\libraries\Wire
Error compiling.

RogerClark
Sun May 08, 2016 7:24 am
I recall there are issues with the various versions of time library

I think @ahull may have an STM32 friendly version of that lib that he used for his PigOScope


Pito
Sun May 08, 2016 7:47 am
I’ve downloaded PaulS “Time” library and renamed the original Arduino one to “TimeAr”.
Now I get following error:
C:\Users\pito\AppData\Local\Temp\build68236732788381724.tmp\Wire\utility\twi.c.o
C:\Users\pito\MyCode\Arduino\libraries\Wire\utility\twi.c:25:20: fatal error: avr/io.h: No such file or directory
#include <avr/io.h>
^
compilation terminated.
Multiple libraries were found for "Wire.h"
Used: C:\Users\pito\MyCode\Arduino\libraries\Wire
Not used: C:\Users\pito\MyCode\Arduino\hardware\Arduino_STM32\STM32F1\libraries\Wire
Error compiling.

Pito
Sun May 08, 2016 8:44 am
Ok it seems it works (SDA1, SCL1)
Start
8:43:23 8 5 2016

ahull
Sun May 08, 2016 11:43 am
If you are interested in using the built in RTC on the STM32F103, you might like to take a look at this project.

More details here.

Code is here.

Image


Pito
Mon May 09, 2016 9:37 am
@ahull – nice project!
I like the DS3231 module as it is precise – in 6months it did +6sec, so I added Aging reg writing to the lib and with +4 written into it may happen I will do a single second off per year :)
Oscillators with 32kHz fork resonator – you must tune them – a pF capacitance change does few seconds a day, moreover there is no temperature compensation. Of course, still ok for most apps.

ahull
Mon May 09, 2016 11:56 am
Pito wrote:@ahull – nice project!
I like the DS3231 module as it is precise – in 6months it did +6sec, so I added Aging reg writing to the lib and with +4 written into it may happen I will do a single second off per year :)
Oscillators with 32kHz fork resonator – you must tune them – a pF capacitance change does few seconds a day, moreover there is no temperature compensation. Of course, still ok for most apps.

Pito
Mon May 09, 2016 3:30 pm
I like this video:
https://www.youtube.com/watch?v=Jp2BOBIzSE0
and my wish list :)
DS3231tuning.JPG

ddrown
Tue May 10, 2016 3:08 pm
ahull wrote:For anything more precise, GPS or NTP (using an ESP8266 perhaps) or “mobile phone time” are probably the simplest options.

doctorlivesey
Tue Nov 22, 2016 10:34 pm
Kenjutsu wrote:I ported the DS3232RTC library of JChristensen and tested it with a DS3231 AT24C32 IIC module precision Real time clock module memory module Arduino. I only tested the SetSerial.ino example program.
The port can be found here: https://github.com/KenjutsuGH/DS3232RTC.git

acronis
Fri Mar 17, 2017 7:20 am
Hello !

my project

#include <DS3232RTC.h> //http://github.com/JChristensen/DS3232RTC
#include "Time.h"
#include <TimeLib.h>

time_t t1;
time_t t2;

tmElements_t tm;

t1=RTC.get();
t2=now();


martinayotte
Fri Mar 17, 2017 2:58 pm
If you look at the DS3232RTC library code, it is returning 0 if it is not able to read the RTC on I2C bus.
So, you need to debug that … Maybe your wiring is wrong, maybe you forgot to have pull-ups, etc …

acronis
Sat Mar 18, 2017 12:31 am
No.
the clock is right.
if you disconnect the power wire from the clock module – clock-stop.
If you set a time and do not remove the battery from the module , the time is read correctly.
But if the battery is removed – the time is reset to 1970.
I think that the problem is to link new libraries<TimeLib.h> and <DS3232RTC.h> .
https://github.com/PaulStoffregen/Time

Naguissa
Sat Mar 18, 2017 1:33 am
I’ve created a very simple rtc library, uRTCLib. If your library is reading rtc correctly check math operations, probably there is a type problem (32 bits vs 8 bits operation).

Kenjutsu
Sat Jul 21, 2018 10:58 am
Just a quick note: Updated to the latest version of DS3232RTC library of JChristensen

Leave a Reply

Your email address will not be published. Required fields are marked *