8 years, 5 months ago.

Generate a 00:00 hour 4 times out of 5 !

Hello,

We just realised that this library, or the RTC physical modules, are returning the correct date but 4 times out of 5, the hour will be equal to 00:00 !...

Note that we have two different devices all using this module and the same code... This behavior is identical on both devices.

Here's our code !

    
    Ds3231 rtc(D14, D15);  // On Board RTC
    ds3231_cntl_stat_t rtc_control_status = {0,0}; 
    ds3231_time_t rtc_time;
    ds3231_calendar_t rtc_calendar;
    
while (1)
    wait_ms(9000){ //Every 9 seconds, read the current Date-time
    epoch_time = rtc.get_epoch();
    strftime(timeBuffer, 50, "%T", localtime(&epoch_time));
    debug.printf("%s\n\r", timeBuffer); //Prints 00:00 most of the time !
}

Question relating to:

1 Answer

8 years ago.

Reviewed code

#include "mbed.h"
#include "ds3231.h"


int main(void)
{
    Ds3231 rtc(D14, D15);  // On Board RTC
    time_t epoch_time; // Declare local variable 

    char timeBuffer[32];
   

    while (1){
        wait_ms(9000); //Every 9 seconds, read the current Date-time
        epoch_time = rtc.get_epoch();
        strftime(timeBuffer, 50, "%T", localtime(&epoch_time));
        printf("%s\n\r", timeBuffer); //Prints the correct value
    }
}


Assigned to Felipe Neira 8 years ago.

This means that the question has been accepted and is being worked on.