KrisKasprzak
Well-known member
All,
I have a Teensy 3.2 with a soldered crystal and when powered via usb it seems to store and display correct time.
I have a 3 volt batter + connected to the VBAT and ground connected to GND (the pin next to pin 0 NOT the pin at the end of the board). Both GND's appear to be connected.
I can program the time, but upon disconnect of power (either USB or by power at 3.3 PIN), the programmed time is not stored. Upload the attached code where I have a setTime with arbitrary time. then comment the setTime upload and see how time is not stored.
How to persist time using setTime?
I have a Teensy 3.2 with a soldered crystal and when powered via usb it seems to store and display correct time.
I have a 3 volt batter + connected to the VBAT and ground connected to GND (the pin next to pin 0 NOT the pin at the end of the board). Both GND's appear to be connected.
I can program the time, but upon disconnect of power (either USB or by power at 3.3 PIN), the programmed time is not stored. Upload the attached code where I have a setTime with arbitrary time. then comment the setTime upload and see how time is not stored.
How to persist time using setTime?
Code:
#include <TimeLib.h>
time_t RTCTime;
void setup() {
Serial.begin(9600);
setSyncProvider(getTeensy3Time);
// setTime(hr,min,sec,day,month,yr);
// comment and see if saved data sticks--it will not, so how do you save dates and time?
setTime(3, 3, 3, 8, 19, 2019);
}
void loop() {
Serial.print(hour());
Serial.print(":");
Serial.print(minute());
Serial.print(":");
Serial.print(second());
Serial.print(" ");
Serial.print(day());
Serial.print("/");
Serial.print(month());
Serial.print("/");
Serial.print(year());
Serial.println();
delay(1000);
}
time_t getTeensy3Time() {
return Teensy3Clock.get();
}