Connecting DS3231 RTC to UNO Q on Arduino IDE

Hi,

Can the DS3231 RTC be connected directly to the Uno Q, since the RTC operates on a supply voltage between 2.3V & 5,5V?

Thanks

Alan

==>

Min    Typ      Max
2.3V   3.3V     5.5V

You cn safely connect Vcc-pin of DS3231 RTC with 3.3V pin of UNO Q. The RTC sould work. Do have a sketch?

Doesn’t the Uno Q have an onboard RTC? That seems like a glaring omission on such an advanced board.

Looks like someone is working on it:
RTC: library implementation by bogdanarduino · Pull Request #231 · arduino/ArduinoCore-zephyr

Hi,

The Uno Q does mot have a battery backed RTC chip, to retain current date & time when powered down.

Hi,

Yes, here it is:

/*********
  Rui Santos & Sara Santos - Random Nerd Tutorials
  Complete instructions at https://RandomNerdTutorials.com/arduino-ds3231-real-time-clock/
*********/

// Based on the RTCLib Library examples: https://github.com/adafruit/RTClib/blob/master/examples
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include "RTClib.h"

RTC_DS3231 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

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

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    while (1) delay(10);
  }

  if (rtc.lostPower()) {
    Serial.println("RTC lost power, let's set the time!");
    // When time needs to be set on a new device, or after a power loss, the
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }

  // When time needs to be re-set on a previously configured device, the
  // following line sets the RTC to the date & time this sketch was compiled
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  // This line sets the RTC with an explicit date & time, for example to set
  // January 21, 2014 at 3am you would call:
  //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}

void loop () {
  // Get the current time from the RTC
  DateTime now = rtc.now();
  
  // Getting each time field in individual variables
  // And adding a leading zero when needed;
  String yearStr = String(now.year(), DEC);
  String monthStr = (now.month() < 10 ? "0" : "") + String(now.month(), DEC);
  String dayStr = (now.day() < 10 ? "0" : "") + String(now.day(), DEC);
  String hourStr = (now.hour() < 10 ? "0" : "") + String(now.hour(), DEC); 
  String minuteStr = (now.minute() < 10 ? "0" : "") + String(now.minute(), DEC);
  String secondStr = (now.second() < 10 ? "0" : "") + String(now.second(), DEC);
  String dayOfWeek = daysOfTheWeek[now.dayOfTheWeek()];

  // Complete time string
  String formattedTime = dayOfWeek + ", " + yearStr + "-" + monthStr + "-" + dayStr + " " + hourStr + ":" + minuteStr + ":" + secondStr;

  // Print the complete formatted time
  Serial.println(formattedTime);

  // Getting temperature
  Serial.print(rtc.getTemperature());
  Serial.println("ºC");

  Serial.println();
  delay(3000);
}

The best answer I can give is maybe. Electrically it will work, but there is an important detail to consider.

If you are using a rechargeable battery on the clock module, the ones I have used require 5V to properly charge the battery. Make sure your supply voltage supports that.

If you are using a CR2032, that is a primary (non-rechargeable) battery. It is intended to be replaced at the end of its life and must not be recharged. If it is a primary battery it should work OK.

Have you run the sketch? Is it working? ost the output.

My DS3231 is working well with UNO Q at Vcc = 3.3V.

Sketch:

#include <Wire.h>
#include "RTClib.h"
#include<Arduino_RouterBridge.h>

RTC_DS3231 rtc;
DateTime myDT;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
byte lastReadSecond = 0;

void setup ()
{
  Bridge.begin();
  Monitor.begin();
  
  rtc.begin();
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  //rtc.adjust(DateTime(2021, 12, 31, 01, 59, 57));
  //set date-time manualy:yr,mo,dy,hr,mn,sec
}

void loop ()
{
  myDT = rtc.now();
  if (lastReadSecond != myDT.second())//wait 1-sec as long as they are equal = 1s has not gones
  {
    lastReadSecond = myDT.second();
    showTime();
  }
}

void showTime()
{
  //update to the new second
  myDT = rtc.now();
  //lastReadSecond = myDT.second();
  //------------------------------
  Monitor.print(myDT.year(), DEC);
  Monitor.print('/');
  //-----------------------------
  byte months = myDT.month();
  Monitor.print(months, DEC);
  Monitor.print('/');
  Monitor.print(myDT.day(), DEC);
  Monitor.print(" (");
  Monitor.print(daysOfTheWeek[myDT.dayOfTheWeek()]);
  Monitor.print(") ");
  //-----------------------------
  byte myHour = myDT.hour();
  if (myHour < 10)
  {
    Monitor.print('0');  //show leading zero
  }
  Monitor.print(myHour, DEC);
  Monitor.print(':');
  //-----------------------------
  byte myMin = myDT.minute();
  if (myMin < 10)
  {
    Monitor.print('0');  //show leading zero
  }
  Monitor.print(myMin, DEC);
  Monitor.print(':');
  //--------------------------
  byte mySec = myDT.second();
  if (mySec < 10)
  {
    Monitor.print('0');  //show leading zero
  }
  Monitor.print(mySec, DEC);
  //----------------------------
  Monitor.println();
}

Output:

2026/2/19 (Thursday) 22:29:34
2026/2/19 (Thursday) 22:29:35
2026/2/19 (Thursday) 22:29:36
2026/2/19 (Thursday) 22:29:37
2026/2/19 (Thursday) 22:29:38

Hi GolamMostafa,

No have not run this code myself yet. But it does come from a reliable source ‘Random Nerd’. I have run many of their sketches in the past & have not found anything that does not work yet.

I have also run many sketches form them on WiFi/ESP32 and they were all working. Now, waiting to see when they will come with sketches for WiFi/UNO Q.

According to Google, it is best to connect the RTC to 3.3Vmsupply voltage, & the charging current is 3 micro amps max.

Here is a working sketch for UNO Q in which the DS3231 is working as an independent thread/task. It may help readers who wish to study the working principles of the Zephyr RTOS and its role in scheduling and managing muti-tasks.

#include <Arduino.h>
#include <Wire.h>
#include <RTClib.h>
#include <zephyr/kernel.h>
#include <Arduino_RouterBridge.h>

/* =========================
   Hardware objects
   ========================= */
RTC_DS3231 rtc;
byte lastReadSecond = 0;

char daysOfTheWeek[7][12] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };

#define RTC_STACK_SIZE 1024
#define RTC_THREAD_PRIO -1

K_THREAD_STACK_DEFINE(rtc_stack, RTC_STACK_SIZE);
struct k_thread rtc_thread_data;

/* =========================
   RTC thread function
   ========================= */
void rtc_task(void *, void *, void *) {
  while (1) {

    DateTime myDT = rtc.now();
    if (lastReadSecond != myDT.second())  //wait 1-sec as long as they are equal = 1s has not gones
    {
      lastReadSecond = myDT.second();
      //update to the new second
      myDT = rtc.now();
      //lastReadSecond = myDT.second();
      //------------------------------
      Monitor.print(myDT.year(), DEC);
      Monitor.print('/');
      //-----------------------------
      byte months = myDT.month();
      Monitor.print(months, DEC);
      Monitor.print('/');
      Monitor.print(myDT.day(), DEC);
      Monitor.print(" (");
      Monitor.print(daysOfTheWeek[myDT.dayOfTheWeek()]);
      Monitor.print(") ");
      //-----------------------------
      byte myHour = myDT.hour();
      if (myHour < 10) {
        Monitor.print('0');  //show leading zero
      }
      Monitor.print(myHour, DEC);
      Monitor.print(':');
      //-----------------------------
      byte myMin = myDT.minute();
      if (myMin < 10) {
        Monitor.print('0');  //show leading zero
      }
      Monitor.print(myMin, DEC);
      Monitor.print(':');
      //--------------------------
      byte mySec = myDT.second();
      if (mySec < 10) {
        Monitor.print('0');  //show leading zero
      }
      Monitor.print(mySec, DEC);
      //----------------------------
      Monitor.println();
    }
  }
}

void setup() {

  Bridge.begin();
  Monitor.begin();
  delay(1000);

  pinMode(LED3_R, OUTPUT);

  Wire.begin();

  if (!rtc.begin()) {
    Monitor.println("DS3231 not found!");
    while (1)
      ;
  }

  Monitor.println("DS3231 OK");
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

  /* Create independent RTC thread */
  k_thread_create(&rtc_thread_data,
                  rtc_stack,
                  RTC_STACK_SIZE,
                  rtc_task,
                  NULL, NULL, NULL,
                  RTC_THREAD_PRIO,
                  0,
                  K_NO_WAIT);
}

/* =========================
   Arduino loop()
   ========================= */
void loop() {
  /* LED3_R blinking handled ONLY here */
  digitalWrite(LED3_R, HIGH);
  delay(500);

  digitalWrite(LED3_R, LOW);
  delay(500);
}

Output:

2026/2/20 (Friday) 00:17:22
2026/2/20 (Friday) 00:17:23
2026/2/20 (Friday) 00:17:24
2026/2/20 (Friday) 00:17:25

No RTC was specified so I assume it is the Typical Chinese DS3231 Module. I also look at the data sheets to be sure.

If so It has:

  • A diode
  • A 200 ohm or 1K resistor from VCC to VBAT
    Then it expects 5V to charge an LIR2032.

With only 3.3V:

  • Charging voltage is too low.
  • Rechargeable battery will not fully charge.

You can check the data sheet:https://www.powerstream.com/p/Lir2032.pdf

It states 4.2V for charging and has a nominal voltage of 3.7V at 0.2C mA.

Circuit diagram for DS3231 beakout board:

Hi,

Thanks, will try that.

That is the circuit I am referring to. You need 4.2 volts to charge the battery, you lose about 0.6 volts through the diode. The forward voltage VF (Voltage Forward) of the 1N4148 diode is typically rated around 1 volt at a forward current of 10 mA. This means that when the diode is conducting, it will have a voltage drop of about 1 volt across it. With a 3V3 source there is nothing to charge the battery. You can run it on 5V but pull up to 3v3 on the I2C, it gives you a small margin for a logic "1" but most of the time it will work if the environment is not to noisy. Hopefully this helps.

Also, try to put the ime on the 8x13 Led Matrix display unit driven by MCU. I am working on it by following this link #11 @philippe86220.

Another solution is to power just the charge circuit with 5V and the rest on 3V3 If using an LIR2032 (rechargeable battery). Something to be careful of is the DS3231 automatically switches to whichever supply is higher Bat/Vcc. If you are using a primary cell just ignore the charge the diode will prevent it from back feeding into your system draining the battery.

Hi GolamMostafa,

Tried your code on the Uno Q. Unfortunately the following Error was produced:

exit status 1

Compilation error: exit status 1