Marcin Saj
Published © GPL3+

Real Time Clock RX8025T

I found an interesting real time clock RX8025T and decided to use it in my projects. I prepared the Arduino library for the RTC.

BeginnerProtip30 minutes737
Real Time Clock RX8025T

Things used in this project

Hardware components

Real Time Clock (RTC) RX8025T
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

PCB Dimensions

Schematics

IC RX8025T Full Datasheet

RTC RX8025T Module – Schematic

How to Use RTC RX8025T Module with Arduino

RTC RX8025T Pinout

IC RX8025T Summary Datasheet

Code

How to generate an interrupt by the RTC (INT output) every second or every minute and handle the int

Arduino
/*----------------------------------------------------------------------*
 * A simple example of how the RTC allows you to generate an interrupt  * 
 * that can be used to regularly read the time and date from the RTC.   *
 *                                                                      *                                                                      
 * Interrupt options:                                                   *
 * "INT_SECOND" - every second,                                         *                        
 * "INT_MINUTE" - every minute.                                         *
 *                                                                      *
 * The MIT License                                                      *
 * Marcin Saj 25 OCT 2022                                               *
 * https://github.com/marcinsaj/RTC_RX8025T                             *
 *----------------------------------------------------------------------*/

#include <RTC-RX8025T.h>      //https://github.com/marcinsaj/RTC_RX8025T
#include <TimeLib.h>          //https://github.com/PaulStoffregen/Time
#include <Wire.h>             //https://arduino.cc/en/Reference/Wire (included with Arduino IDE)

//Declare structure that allows convenient access to the elements of time like hours, minutes and seconds
tmElements_t tm;

//Arduino pin to handle the interrupt from the RTC
const byte interruptPin = 2;
//A flag to store information about an interrupt
volatile byte interruptState = LOW;

void setup(void)
{ 
  Serial.begin(9600);
  delay(3000);

  //Pin and interrupt handling subroutine assignment
  attachInterrupt(digitalPinToInterrupt(interruptPin), interruptHandling, FALLING);
  pinMode(interruptPin, INPUT_PULLUP);
  
  //RX8025T initialization
  RTC.init();
          
  //The Time library is a software RTC. 
  //"system time" it is referring to the current time according to the software RTC.
  //Set the system time to 10h 23m 30s on 25 Oct 2022
  setTime(10, 23, 30, 25, 10, 22);
  //Set the RTC from the system time
  RTC.set(now());

  //Time update interrupt initialization.
  //Interrupt generated by RTC (INT output): 
  //"INT_SECOND" - every second,
  //"INT_MINUTE" - every minute.
  RTC.initTUI(INT_MINUTE);

  //"INT_ON" - turn ON interrupt generated by RTC (INT output),
  //"INT_OFF" - turn OFF interrupt.
  RTC.statusTUI(INT_ON);
}

void loop(void)
{
  if(interruptState == HIGH)
  {
    //Read the time from the RTC and store it in the tm structure
    RTC.read(tm);
    printDateTime();
    interruptState = LOW;
  }
}

void printDateTime(void)
{
    Serial.print("Date: ");
    //Time library macro for convenient Year conversion to calendar format
    Serial.print(tmYearToCalendar(tm.Year));
    Serial.print(".");
    if(tm.Month < 10) Serial.print("0");
    Serial.print(tm.Month);
    Serial.print(".");
    if(tm.Day < 10) Serial.print("0");
    Serial.print(tm.Day);
    Serial.print("  ");
  
    Serial.print("Time: ");
    if(tm.Hour < 10) Serial.print("0");
    Serial.print(tm.Hour);
    Serial.print(":");
    if(tm.Minute < 10) Serial.print("0");
    Serial.print(tm.Minute);
    Serial.print(":");
    if(tm.Second < 10) Serial.print("0");
    Serial.println(tm.Second);
}

void interruptHandling(void)
{
  interruptState = HIGH; 
}

How to generate square wave by the RTC with preset frequencies: 32.768 kHz, 1024 Hz, 1 Hz

Arduino
/*----------------------------------------------------------------------*
 * A simple example of how to handle the FOUT output of the RTC         *
 * to generate square wave with different frequencies.                  *
 *                                                                      *                                                                      
 * Frequency options:                                                   *
 * "FOUT_32768" - 32.768kHz,                                            *                        
 * "FOUT_1024"  - 1024Hz,                                               *
 * "FOUT_1"     - 1Hz.                                                  *
 *                                                                      *
 * The FOE RTC input is used to control                                 *
 * the on-off switching of the FOUT output. FOE "HIGH" - FOUT active    *                                                                 
 *                                                                      *
 * The MIT License                                                      *
 * Marcin Saj 25 OCT 2022                                               *
 * https://github.com/marcinsaj/RTC_RX8025T                             *
 *----------------------------------------------------------------------*/

#include <RTC_RX8025T.h>      //https://github.com/marcinsaj/RTC_RX8025T
#include <TimeLib.h>          //https://github.com/PaulStoffregen/Time
#include <Wire.h>             //https://arduino.cc/en/Reference/Wire (included with Arduino IDE)

//Declare structure that allows convenient access to the elements of time like hours, minutes and seconds
tmElements_t tm;

//Arduino pin to handle the FOE input of the RTC
//If "frequencyPin" (FOE) "HIGH" then FOUT output is active
const byte frequencyPin = 3;

#define FOUT_ON   HIGH
#define FOUT_OFF  LOW

void setup(void)
{ 
  Serial.begin(9600);
  delay(3000);

  pinMode(frequencyPin, OUTPUT);
  digitalWrite(frequencyPin, LOW);
  
  //RX8025T initialization
  RTC.init();
          
  //The Time library is a software RTC. 
  //"system time" it is referring to the current time according to the software RTC.
  //Set the system time to 10h 23m 30s on 25 Oct 2022
  setTime(10, 23, 30, 25, 10, 22);
  //Set the RTC from the system time
  RTC.set(now());

  //Frequency output initialization.
  //Frequency generated by RTC (FOUT output): 
  //"FOUT_32768" - 32.768kHz,
  //"FOUT_1024"  - 1024Hz,
  //"FOUT_1"     - 1Hz.
  RTC.initFOUT(FOUT_1);

  //"FOUT_ON" - turn ON frequency FOUT output,
  //"FOUT_OFF" - turn OFF frequency FOUT output.
  frequencyOutput(FOUT_ON);
}

void loop(void)
{
    //Read the time from the RTC and store it in the tm structure
    RTC.read(tm);
    printDateTime();

    delay(1000);
}

void printDateTime(void)
{
    Serial.print("Date: ");
    //Time library macro for convenient Year conversion to calendar format
    Serial.print(tmYearToCalendar(tm.Year));
    Serial.print(".");
    if(tm.Month < 10) Serial.print("0");
    Serial.print(tm.Month);
    Serial.print(".");
    if(tm.Day < 10) Serial.print("0");
    Serial.print(tm.Day);
    Serial.print("  ");
  
    Serial.print("Time: ");
    if(tm.Hour < 10) Serial.print("0");
    Serial.print(tm.Hour);
    Serial.print(":");
    if(tm.Minute < 10) Serial.print("0");
    Serial.print(tm.Minute);
    Serial.print(":");
    if(tm.Second < 10) Serial.print("0");
    Serial.println(tm.Second);
}

//If "frequencyPin" (FOE) "HIGH" then FOUT output is active
void frequencyOutput(bool state)
{
  digitalWrite(frequencyPin, state); 
}

How to set and display the RTC date and time

Arduino
/*----------------------------------------------------------------------*
 * A simple example of how to set the date and time,                    *
 * read the date and time from the RX8025T RTC and display them.        *
 *                                                                      *
 * The MIT License                                                      *
 * Marcin Saj 25 OCT 2022                                               *
 * https://github.com/marcinsaj/RTC_RX8025T                             *
 *----------------------------------------------------------------------*/

#include <RTC-RX8025T.h>      //https://github.com/marcinsaj/RTC_RX8025T
#include <TimeLib.h>          //https://github.com/PaulStoffregen/Time
#include <Wire.h>             //https://arduino.cc/en/Reference/Wire (included with Arduino IDE)

//Declare structure that allows convenient access to the elements of time like hours, minutes and seconds
tmElements_t tm;

void setup(void)
{ 
  Serial.begin(9600);
  delay(3000);
  
  //RX8025T initialization
  RTC.init();
          
  //The Time library is a software RTC. 
  //"system time" it is referring to the current time according to the software RTC.
  //Set the system time to 10h 23m 30s on 25 Oct 2022
  setTime(10, 23, 30, 25, 10, 22);
  //Set the RTC from the system time
  RTC.set(now());
}

void loop(void)
{
  //Read the time from the RTC and store it in the tm structure
  RTC.read(tm);
  printDateTime();

  delay(1000);
}

void printDateTime(void)
{
  Serial.print("Date: ");
  //Time library macro for convenient Year conversion to calendar format
  Serial.print(tmYearToCalendar(tm.Year));
  Serial.print(".");
  if(tm.Month < 10) Serial.print("0");
  Serial.print(tm.Month);
  Serial.print(".");
  if(tm.Day < 10) Serial.print("0");
  Serial.print(tm.Day);
  Serial.print("  ");
  
  Serial.print("Time: ");
  if(tm.Hour < 10) Serial.print("0");
  Serial.print(tm.Hour);
  Serial.print(":");
  if(tm.Minute < 10) Serial.print("0");
  Serial.print(tm.Minute);
  Serial.print(":");
  if(tm.Second < 10) Serial.print("0");
  Serial.println(tm.Second); 
}

How to set and display the RTC date and time with the names of days of the week and months

Arduino
/*----------------------------------------------------------------------*
 * A simple example of how to set the date and time,                    *
 * read the date and time from the RX8025T RTC and display them.        *
 *                                                                      *
 * In addition, it shows how to display the date                        *
 * with the names of the days of the week and months.                   *
 *                                                                      *
 * The MIT License                                                      *
 * Marcin Saj 25 OCT 2022                                               *
 * https://github.com/marcinsaj/RTC_RX8025T                             *
 *----------------------------------------------------------------------*/

#include <RTC-RX8025T.h>      //https://github.com/marcinsaj/RTC_RX8025T
#include <TimeLib.h>          //https://github.com/PaulStoffregen/Time
#include <Wire.h>             //https://arduino.cc/en/Reference/Wire (included with Arduino IDE)

//Declare structure that allows convenient access to the elements of time like hours, minutes and seconds
tmElements_t tm;

const char * dayOfWeekName[] = 
{
  "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
};

const char * monthName[] = 
{
  "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
};

void setup(void)
{ 
  Serial.begin(9600);
  delay(3000);
  
  //RX8025T initialization
  RTC.init();
          
  //The Time library is a software RTC. 
  //"system time" it is referring to the current time according to the software RTC.
  //Set the system time to 10h 23m 30s on 25 Oct 2022
  setTime(10, 23, 30, 25, 10, 22);
  //Set the RTC from the system time
  RTC.set(now());
}

void loop(void)
{
  //Read the time from the RTC and store it in the tm structure
  RTC.read(tm);
  printDateTime();

  delay(1000);
}

void printDateTime(void)
{
  Serial.print("Date: ");
  //Time library macro for convenient Year conversion to calendar format
  Serial.print(tmYearToCalendar(tm.Year));
  Serial.print(" ");
  Serial.print(monthName[tm.Month]);
  Serial.print(" ");
  if(tm.Day < 10) Serial.print("0");
  Serial.print(tm.Day);
  Serial.print(" ");
  //tm.Wday stores values from 1 to 7, so we have to subtract 1 to correctly read the names from the array
  Serial.print(dayOfWeekName[tm.Wday - 1]);  
  
  Serial.print("     Time: ");
  if(tm.Hour < 10) Serial.print("0");
  Serial.print(tm.Hour);
  Serial.print(":");
  if(tm.Minute < 10) Serial.print("0");
  Serial.print(tm.Minute);
  Serial.print(":");
  if(tm.Second < 10) Serial.print("0");
  Serial.println(tm.Second); 
}

Arduino Library for RX8025T RTC

Credits

Marcin Saj

Marcin Saj

28 projects • 29 followers
I am currently involved in the development of the Flipo.io and NixieTester.com project.

Comments