RTC Battery size

Status
Not open for further replies.

Davidelvig

Well-known member
  • Is it always a CR2032 sized coin cell for powering a real-time clock in the Teensy? Anything smaller (physical size)?
  • How long should a CR2032 last performing the RTC function?
  • Do I need to do anything in the sketch to keep the clock running (or just the added crystal, maybe caps, and the battery)?
Thanks!
Dave
 
I'm using a CR1220 to power the RTC on a few teensy 3.5s. I haven't had to replace the battery yet for about 15 months.
 
I use the CR2032 and all you need to do is solder the crystal and add some code.

Here's the code I use

// global location
#include <TimeLib.h> // teensy time library
#define TIME_HEADER "T"
time_t RTCTime;
int hours = hour();
int minutes = minute();
int seconds = second();
int days = day();
int months = month();
int years = year();

// in setup
setSyncProvider(getTeensy3Time);
RTCTime = ProcessSyncMessage();
if (RTCTime != 0) {
Serial.println("Teensy3Clock.set(RTCTime)");
Teensy3Clock.set(RTCTime); // set the RTC
setTime(RTCTime);
}


// in loop or where ever you need to know the time
if (hour() > 12) {
Serial.print(hour() - 12);
}
else {
Serial.print(hour());
}
Serial.print(F(":"));
if (minute() < 10) {
Serial.print(F("0"));
}
Serial.print(minute());
Serial.print(F(":"));
if (second() < 10) {
Serial.print(F("0"));
}
Serial.print(second());


// if you need to let the user set the time
// get from the user and pass to setTime
setTime(hours, minutes, seconds, days, months, years);
Teensy3Clock.set(now());
RTCTime = now();



..at least I think i included all the calls from my code :)
 
Status
Not open for further replies.
Back
Top