Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: RTC Battery size

  1. #1
    Senior Member Davidelvig's Avatar
    Join Date
    Aug 2015
    Location
    Wisconsin
    Posts
    284

    RTC Battery size

    • 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

  2. #2
    Member
    Join Date
    Aug 2018
    Location
    Brisbane, Australia
    Posts
    24
    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.

  3. #3
    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

  4. #4
    Senior Member Davidelvig's Avatar
    Join Date
    Aug 2015
    Location
    Wisconsin
    Posts
    284
    Thanks, all!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •