Teensy 4.1 3.3V clock battery for keeping time

Dogbone06

Well-known member
Hello,

I've got a custom design made, where I connected a CR2032 battery to the VDD_SNVS_IN pin, from what I can see in the Teensy 4.1 schematic it should work.

I set the time which works fine, I then cut the ordinary power to the board and then start it up again, the time is reset. Even tho the clock battery is providing power to VDD_SNVS_IN.

Am I missing something here?

VBAT is the clock battery positive side.
D2, D6 and D9 are all the same. D6 and D9 has been there always and works fine. VBAT and D2 is new.

1715022262068.png
 
Did you call 'setSyncProvider' to tell the time library to use the real time clock. Here is the setup code from TimeTeensy3.ino:

Code:
#include <TimeLib.h>

void setup()  {
  // set the Time library to use Teensy 3.0's RTC to keep time
  setSyncProvider(getTeensy3Time);

  Serial.begin(115200);
  while (!Serial);  // Wait for Arduino Serial Monitor to open
  delay(100);
  if (timeStatus()!= timeSet) {
    Serial.println("Unable to sync with the RTC");
  } else {
    Serial.println("RTC has set the system time");
  }
}

The example code is in File > Examples > Time > TimeTeensy3.

While that is the code from the example, I would change the while (!Serial) line to:

Code:
// Wait for Arduino Serial Monitor to open or for 3 seconds in case there is no serial monitor
while (!Serial && (millis () < 3000UL))  
  ;

Here is the documentation: https://www.pjrc.com/teensy/td_libs_Time.html#teensy3

It appears the documentation has not been updated for the Teensy 4.0/4.1/micromod, but in theory it should work. Note, like the Teensy 3.5/3.6, you do not have to solder a crystal to the Teensy like you needed to do for the Teensy 3.0, 3.1, or 3.2.
 
Did you call 'setSyncProvider' to tell the time library to use the real time clock. Here is the setup code from TimeTeensy3.ino:

Code:
#include <TimeLib.h>

void setup()  {
  // set the Time library to use Teensy 3.0's RTC to keep time
  setSyncProvider(getTeensy3Time);

  Serial.begin(115200);
  while (!Serial);  // Wait for Arduino Serial Monitor to open
  delay(100);
  if (timeStatus()!= timeSet) {
    Serial.println("Unable to sync with the RTC");
  } else {
    Serial.println("RTC has set the system time");
  }
}

The example code is in File > Examples > Time > TimeTeensy3.

Here is the documentation: https://www.pjrc.com/teensy/td_libs_Time.html#teensy3

It appears the documentation has not been updated for the Teensy 4.0/4.1/micromod, but in theory it should work. Note, like the Teensy 3.5/3.6, you do not have to solder a crystal to the Teensy like you needed to do for the Teensy 3.0, 3.1, or 3.2.
I will try this for sure. I was hoping that there was something like this that I had missed.

Regarding the crystal, yes indeed, all needed should be the 3.3V battery.

I’ll update here if it works or not.
 
I've got a custom design made, where I connected a CR2032 battery to the VDD_SNVS_IN pin, from what I can see in the Teensy 4.1 schematic it should work.
Hoping that sketch worked? Indeed it provides the 'link' from RTC hardware to the usable MCU time keeper.

Assuming this is a new connect added after the DevBd 4.0 and not present on that board? the one label copied from T_MM design isn't the RTC Batt right?
 
Hoping that sketch worked? Indeed it provides the 'link' from RTC hardware to the usable MCU time keeper.

Assuming this is a new connect added after the DevBd 4.0 and not present on that board? the one label copied from T_MM design isn't the RTC Batt right?
Gonna try tonight, this is not the devboard, it's another board I made for a weekend project. The above makes sense tho and should work.
 
It works! Thanks for the help.

For anyone else with the same problem as I had. Just add this:

Code:
time_t getTeensy3Time()
{
  return Teensy3Clock.get();
}

In setup or your custom init function place this:
Code:
setSyncProvider(getTeensy3Time);

Ignore the "Teensy 3", it works on Teensy 4's as well.
 
Last edited:
Back
Top