leomil72 / swRTC

swRTC is a library that implements a software-RTC on an Arduino board or an Atmel microcontroller
36 stars 16 forks source link

unix timestamps don't seem to work #6

Closed keebler411 closed 6 years ago

keebler411 commented 6 years ago

When I run this program the initial timestamp is: 4294880896 not zero like I would expect. Setting the timestamp indirectly with the date/time functions works.

`#include

include

swRTC rtc; //create a new istance of the lib

void setRTC(int year, int month, int day, int hour, int min, int sec) { rtc.setTime((byte)hour, (byte)min, (byte)sec); rtc.setDate((byte)day, (byte)month, year); }

void setupRTC() { rtc.stopRTC(); //stop the RTC // Set software RTC to default date/time //rtc.setDate(1, 1, 1970); //rtc.setTime(0,0,0); //setRTC(1970,1,1,0,0,0); rtc.setClockWithTimestamp(0, 1970); rtc.startRTC(); // start the RTC }

void setup() { Serial.begin(9600); setupRTC(); }

void loop() { Serial.println(rtc.getTimestamp(1970)); } `

leomil72 commented 6 years ago

It should be fixed now in 1.2.9.