Hi,
I'm using the Teensy RTC for keeping track of the my datalogger logfiles. https://github.com/Flydroid/AKX-Logger/blob/master/AKXLogger.ino
To sync the RTC with the current time i found that the __TIME__ and __DATE__ macros.
work sufficiently well. When i compile, the current time gets stored inside Teensy and the RTC synced in the setup() routine (see SetTimeCompile() function at the end of the .ino).
This only has to be done once after compile and upload. Every time thereafter the Teensy is restarted, the RTC should provide
the correct time to the Time library.
The two ways that i came up with to do this, to run the sync with the compile time only once are:
- Have a Byte in EEPROM work as a flag, which is set to a specific value after the Teensy starts for the first time after the upload.
The sync functions checks if this flag has been check and just uses the time provided by the RTC.
PROBLEM: If i have to reupload some changes to Teensy, the EEPROM doesn't get wiped and the flag is still set.
Question: Is there a way to force EEPROM wipe on upload?
- To compare the time_t value of the RTC versus the one from the compile time. The value from the compile is lower eq. in the past compared to the one from the RTC.
PROBLEM: If the RTC is already running a time in the future, eq. the time_t value is higher on compile time it will never sync the RTC.
I know this is probably not the most straight forward way of getting correct time to Teensy RTC but I found that having a synchronization over Serial with a program running on the pc
isn't working well either. Maybe my design is just flawed and I overcomplicate things...
I'm using the Teensy RTC for keeping track of the my datalogger logfiles. https://github.com/Flydroid/AKX-Logger/blob/master/AKXLogger.ino
To sync the RTC with the current time i found that the __TIME__ and __DATE__ macros.
work sufficiently well. When i compile, the current time gets stored inside Teensy and the RTC synced in the setup() routine (see SetTimeCompile() function at the end of the .ino).
This only has to be done once after compile and upload. Every time thereafter the Teensy is restarted, the RTC should provide
the correct time to the Time library.
The two ways that i came up with to do this, to run the sync with the compile time only once are:
- Have a Byte in EEPROM work as a flag, which is set to a specific value after the Teensy starts for the first time after the upload.
The sync functions checks if this flag has been check and just uses the time provided by the RTC.
PROBLEM: If i have to reupload some changes to Teensy, the EEPROM doesn't get wiped and the flag is still set.
Question: Is there a way to force EEPROM wipe on upload?
- To compare the time_t value of the RTC versus the one from the compile time. The value from the compile is lower eq. in the past compared to the one from the RTC.
PROBLEM: If the RTC is already running a time in the future, eq. the time_t value is higher on compile time it will never sync the RTC.
I know this is probably not the most straight forward way of getting correct time to Teensy RTC but I found that having a synchronization over Serial with a program running on the pc
isn't working well either. Maybe my design is just flawed and I overcomplicate things...