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
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
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>
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.
I think @ahull may have an STM32 friendly version of that lib that he used for his PigOScope
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.
Start
8:43:23 8 5 2016
More details here.
Code is here.
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.
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.
The port can be found here: https://github.com/KenjutsuGH/DS3232RTC.git
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();
So, you need to debug that … Maybe your wiring is wrong, maybe you forgot to have pull-ups, etc …
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