There is an 1307 RTC module emulator for Arduino: DS1307Emulator.
You can set this emulator running and save seconds to struct tm *timeStructure
and afterwards converting the structure to a time_t
variable using time.h functions
DS1307Emulator.init(13);
DS1307Emulator.bufferUserData();
DS1307Emulator.writeToRTC(0x00); // set address 0
DS1307Emulator.writeToRTC(0x00); // start the RTC issuing the clock run command at address 0
DS1307Emulator.setUserData();
Adresses are as follows:
- 0x00 - seconds
- 0x01 - minutes
- 0x02 - hours
If you want to use weekdays, date, year etc. refer to the DS1307 datasheet or check examples on the link I provided.
For reading seconds:
DS1307Emulator.bufferUserData();
DS1307Emulator.writeToRTC(0x00);
temp = DS1307Emulator.readUserData();
temp
now holds seconds in binary format, you may want to convert them to dec.
Check out examples in the link I gave for full operation.