The MAX31334 Real Time Clock & Why to use it

Table of contents

RoadTest: Enroll to Review the ADI Ultra-Low-Power RTC with Integrated Power Switch

Author: taifur

Creation date:

Evaluation Type: Evaluation Boards

Did you receive all parts the manufacturer stated would be included in the package?: False

What other parts do you consider comparable to this product?: MAX31331, MAX31328, MAX31329, MAX31341, MAX31343, Maxim DS1390U-33, DS1339U-2

What were the biggest problems encountered?: Downloading the Windows application mentioned in the user guide.

Detailed Review:

First Look

I received the MAX31334 shield evaluation kit (EV kit) in good condition. After opening the kit from the box I was looking for the RTC chip and I really worked hard to find the itsy-bitsy little tiny RTC IC on the Kit. The shield is Arduino compatible and comes with an MAX32625PICO board connected. Possibly the primary reason for the MAX32625PICO is for interfacing the MAX31334 RTC with the Windows application. Though the datasheet mentioned that, the kit should include a Micro-USB cable I did not receive any cable with the Kit. The manufacturer does not call it an Arduino shield nor the Arduino word is highlighted in the datasheet but seeing it you may think it is designed for Arduino. The kit has lots of test points and jumpers and I believe these give me huge flexibility while testing and working with it. 

On the bottom of the board, I see a QR which directs me to the analog main page but logically it should lead me to the product page. It is not a big deal and the link may change anytime. I have worked with several RTC chips before from Maxim but this is the first time I realized the RTC chip may also work with a Supercapacitor instead of a coin cell. Yes, the board came with a supercapacitor instead of a CMOS battery. There is also a push switch on the board. I don't know what is the role of the switch but I will discover its functionality later. 

Reading the Materials

To get started with a new thing it is always required to read reference manuals like datasheets, user guides, and getting started guides. So, I downloaded the Kit user guide and started reading it carefully. The first new thing I discovered was that this MAX3133 RTC has an integrated power switch. This power switch can be used to power on/off other devices like the host microcontroller programmatically. This is a new feature I did not find in other RTCs I worked on before. To learn details about this feature I switched to the device datasheet and found that this power switch can handle up to 500mA which is more than enough I believe. The switch has 57mohm on resistance which can create a maximum of 3.3mW power losses and it is reasonable enough. The switch can be turned ON or OFF for a maximum of 1 hour which is not a long time at all.

Another new thing in this RTC I observed was the trickle charging capability of the VBAT pin that gives us the opportunity to use a Supper-cap instead of a CMOS battery. I am not sure yet how long the supper-cam can help to retain the time without the power supply. I will try to explore it later. Another interesting addition is a digital Schmitt trigger input (DIN) which can be used to record timestamps and/or generate an interrupt on the falling/rising edge. The DIN pan can also be utilized to control the power switch. Another good thing about this RTC is it works with very little voltage which is 1.62V.

Getting Started Experience

The 9 pages user guide mentioned that a PC software is available for testing and evaluating the MAX31334 real-time clock EV kit and it also includes a web link for downloading the software. But surprisingly the link leads to Analog Devices main page instead of the product page. I searched for the product page with the MAX31334 keyword and I was in luck. Unfortunately, I did not find any software on the product page to download rather I noticed the data sheet and a zip file containing the shield ODB files.

I was a bit upset and asked for help from the support team. Finally, I was able to manage the GUI software. It is really a good tool for experimenting and understanding all the internal details of an RTC. I connected the RTC Evaluation Kit to my PC using a micro USB cable but I was not getting any data. From the Kit user guide, I understood that JU4 is configured for external power. First, I was trying to work with it without any external power supply. So, I reconfigured the JU4 to provide power to RTC from the PICO microcontroller board. It was working as expected.

The RTC started counting from January 1, 2000, and the time started from 0:00:00. The default time was set for 24h format and all the alarms and interrupts were disabled. I set the date and time as shown in the image below. Setting the date and time using the GUI was very easy.

The trickle charger is OFF by default. For this reason, RTC was unable to retain the configured time, and in every reconnection, it started from January 1, 2000, with time from 0:00:00. So, to maintain the correct time the RTC needs backup power after removing the main power which will be drawn from the supper-cap. For charging the supercapacitor, I enabled the trickle charger with a maximum charging rate by choosing 3K resistor without the diode. The rate is defined in the device datasheet on page 14 and a screenshot is added below.

I was curious to know for how many hours or days the supercapacitor is capable of providing power to the RTC circuit in the absence of the main power source. Unfortunately, the Kit user guide does not provide any information about the backup time of the supercapacitor. I intended to calculate the backup time for the installed super-cap. Datasheet provides the time-keeping cutoff voltage and time-keeping current but In order to calculate the backup time I also need to know the self-discharge characteristic of the supercapacitor and its temperature dependency. I did not find any of that information on the supercapacitor datasheet. So, any accurate calculation for finding the backup time was not easy. Rather, I will try to find an approximate time using the manual method.

Power Switch: A Use Case

One interesting feature of MAX31334 RTC is it has an integrated power switch. The switch can be used to control the power to the host device. Suppose we want to make a temperature and humidity monitoring device that will read the temperature and humidity data of a remote location every hour and send the data to the cloud. The device should be battery-operated. As a battery-operated device, it should be very power-efficient. The device reads and sends data once in an hour which may take a couple of seconds to complete its job. So for the rest of the time (almost all the time) the device passes idle time. If we keep the device active it will consume a huge amount of power for doing nothing. A good solution is a deep sleep. But the next question is who will wake up the device from the sleep at right time. Some microcontrollers use internal timers to wake them up but the timer has bit limitation. For example, ESP8266, a very common IoT chip has timer of 32 bits wide that allows it to sleep a maximum of approximately 71 minutes at a time. With any larger value it never wakes up.

For some use cases, it is good enough to measure sensor parameters once or two times a day. For example, measuring the soil moisture of your planter every morning and evening is wise enough. Measuring the soil parameter and sending the data to the cloud can take 15-20 seconds. So, your device needs to keep active for a maximum of 1 minute a day. If it is a battery-operated device it must be in deep sleep almost all the time of the day. The default wake-up mechanism will not work here. In such a situation RTC like the MAX31334 with a power switch can be the best solution. Read the sensor data, send it to the cloud, set the wake-up alarm, and send the I2C command to turn OFF the power switch. Thats it. The MAX31334 RTC will take care of your device. Thus you can wake up your device after any duration you like.

To do it practically I am going to connect an ESP8266-01 Wi-Fi Module with the MAX31334 shield. First I will operate the RTC chip from my computer. So, I only connected the TP10 (PSW) pin to the 3.3V input of the ESP8266-01 board and the ground pin of the RTC shield to the ground of the ESP8266-01 board. My test circuit is shown in the image below.

By default, the power switch is in the ON state. You need to turn it OFF by setting the SLP bit (Bit 7) of the SLEEP_CONFIG (0x7) register of the RTC. But before enabling the SLP (Sleep Enable) bit you must enable at least one wakeup source (DWE, TWE, A1WE, A2WE). The following screenshot is captured from page # 28 of the datasheet of MAX31334 RTC which explains the sleep configuration.

I am going to use Alarm1 here to wake up the device. I set the alarm for my desired time (when I want to enable my ESP8266 device again) from the MAX31334 RTC Software as shown in the screenshot.

Then from the Power Switch tab, I selected Alarm1 as the Wakeup Enable and SET the SLP bit. The power switch went to the OFF state immediately.

The ESP8266 module was enabled again immediately after matching the RTC current time with the Alarm 1 time. Watch the following short video.

Now, let's do it programmatically from the actual device. As I am using ESP8266-01 for my IoT device I need to control the RTC from my ESP8266 chip. The following code is written for the ESP chip using the Arduino platform. Luckily I found the official Arduino library for MAX31334 RTC in GitHub. So, I was able to write the code without so much effort (if you get any error message for the ESP8266 board you may need to make some changes to the library). You need to add this library for the successful compilation of the following code. In the code, I set an alarm after three hours from the current time, doing my sensor-related work and entering sleep mode. After entering sleep ESP will lose power until the next alarm which is going to be active after three hours. So, the device will turn off for three hours.

#include <AnalogRTCLibrary.h>

MAX31334 *rtc;

const char *days[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",  "Sunday"};

void set_test_time(tm * testTime)
    /*Date: 14/11/2023 Day: Saturday
      Time: 12:25:00*/
    testTime->tm_sec = 00;
    testTime->tm_min = 25;
    testTime->tm_hour = 12;
    testTime->tm_mday = 14;
    testTime->tm_mon = 11;
    testTime->tm_year = 123;
    testTime->tm_wday = 5;
    testTime->tm_yday = 0;
    testTime->tm_isdst = 0;

void print_time(tm *rtc_ctime, uint16_t *sub_sec = NULL) {
    Serial.print("Date: ");
    Serial.print(rtc_ctime->tm_mon + 1);
    Serial.print(rtc_ctime->tm_year + 1900);
    Serial.print(" Day: ");

    Serial.print("Time: ");
    if(sub_sec == NULL) {
    } else {

void set_alarm1(tm *rtc_ctime){
    tm rtc_atime;
    int next_hour = rtc_ctime->tm_hour + 3; //set alarm every three hours
    if(next_hour>=24) next_hour = next_hour - 24;
    int next_minute = rtc_ctime->tm_min; 
    int next_second = rtc_ctime->tm_sec;
    rtc_atime.tm_hour = next_hour;
    rtc_atime.tm_min = next_minute;
    rtc_atime.tm_sec = next_second;
    rtc_atime.tm_mday = 10;
    rtc_atime.tm_wday = 4;
    rtc_atime.tm_mon = 8;
    rtc_atime.tm_year = 2022 - 1900;
    //alarm if Hours, Minutes and Seconds match
    if (rtc->set_alarm(MAX3133X::ALARM1, &rtc_atime, MAX3133X::ALARM_PERIOD_DAILY)) {
        Serial.println("Error while setting alarm1!");
    } else {
        Serial.println("Set Alarm1");
void setup() {
    max3133x_status_reg_t status_reg;
    tm rtc_ctime;

    Serial.println("MAX3133x RTC Sleep Example");


    rtc = new MAX31334(&Wire);
    if(rtc->begin()) {
        Serial.println("Error while rtc begin!");

    if(rtc->trickle_charger_enable(0, true)) {
        Serial.println("Error trickle charge enable");
    if (rtc->set_time(&rtc_ctime)) {
        Serial.println("Error while set time!");
    } else {
        Serial.println("Set Time");
    if (rtc->get_time(&rtc_ctime)) {
        Serial.println("Error while getting time!");
    } else {
    if (rtc->wakeup_enable(A1IE|DIE)) {
        Serial.println("Error while wakeup enable!");
    } else {
        Serial.println("Wakeup Enable");
    ///do your work here

    //aftr finishing your work turn off the power switch
    if (rtc->sleep_enter()) {
        Serial.println("Error while Sleep Enter");
    } else {
        Serial.println("Sleep Enter");

void loop(){

After adding your necessary sensor-related code you need to upload it to the ESP8266 and connect the SCL and SDA pin of MAX31334 shield to the SCL and SDA pin of the ESP chip. ESP8266 power pin will be connected to TP10 like before and of course there must be a common ground between RTC and ESP. My connection was as follows:

You have to remove the PICO board from the RTC shield for connecting with the ESP module.


The MAX31334 RTC Shield Kit is a really good tool for experimenting & understanding RTC. The GUI software helped to make me clear all the functionality of the MAX31334 RTC chip. At the same time, it helped me to clear some of my previous RTC-related confusion. I liked the Power Switch functionality very much. It is the newest thing I have ever seen in an RTC (it can be a limitation of my knowledge). Using this functionality a battery-operated power-efficient device can be made very easily where you can turn off your device for any duration and make it wake up at the right time. As the device will be completely turned off there is even no deep sleep current!