Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Arduino DS3231 Real Time Clock (RTC) with Temperature Monitor
Arduino Projects

Arduino DS3231 Real Time Clock (RTC) with Temperature Monitor

Mamtaz AlamBy Mamtaz AlamUpdated:August 22, 20223 Comments3 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Arduino & DS3231 Based Real Time Clock (RTC) & Temperature Monitor
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

We are happy to present to you Arduino & DS3231 Based Real Time Clock (RTC) & Temperature Monitor. This is a simple real time clock with time, day, date using Arduino UNO board, and DS3231 module. We have also added a temperature monitor to further extend this project.

The alternative IC for DS3231 is DS1307. The DS3231 RTC has a built-in alarm function as well as a temperature sensor with a resolution of 0.25 and an accuracy of ±3°C which makes this project easier.

You can check the previous version of a similar project here:
1. Arduino DS3231 Real Time Clock with Alarm & Temperature

  1. ESP8266 and DS3231 Based Real Time Clock (RTC)

  2. Interfacing PCF8563 Real Time Clock Module with Arduino

  3. GPS Clock using Arduino


Components Required:

To design Arduino & DS3231 Based Real Time Clock (RTC) & Temperature Monitor, we need the following components.

  1. Arduino board
  2. DS3231 RTC Module
  3. 16 x 2 LCD
  4. 3V coin cell battery
  5. Breadboard
  6. Jumper wires



DS3231 RTC Module:

Introduction:

The DS3231 is a low-cost, extremely accurate I²C real-time clock (RTC) with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input and maintains accurate timekeeping when main power to the device is interrupted.

Arduino & DS3231 Based Real Time Clock (RTC) & Temperature Monitor

The RTC maintains seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an active-low AM/PM indicator. Two programmable time-of-day alarms and a programmable square-wave output are provided.

A precision temperature-compensated voltage reference and comparator circuit monitors the status of VCC to detect power failures, to provide a reset output, and to automatically switch to the backup supply when necessary. Additionally, the active-low RST pin is monitored as a pushbutton input for generating a µP reset.

Key Features:

  1. Highly Accurate RTC Completely Manages All Timekeeping Functions
  2. Real-Time Clock Counts Seconds, Minutes, Hours, Date of the Month, Month,
    Day of the Week, and Year, with Leap-Year Compensation Valid Up to 2100
  3. Accuracy ±2ppm from 0°C to +40°C
  4. Accuracy ±3.5ppm from -40°C to +85°C
  5. Digital Temp Sensor Output: ±3°C Accuracy
  6. Register for Aging Trim
  7. Active-Low RST Output/Pushbutton Reset Debounce Input
  8. Two Time-of-Day Alarms
  9. Programmable Square-Wave Output Signal
  10. Simple Serial Interface Connects to Most Microcontrollers
  11. Fast (400kHz) I2C Interface
  12. Battery-Backup Input for Continuous Timekeeping
  13. Low Power Operation Extends Battery-Backup Run Time
  14. 3.3V Operation
  15. Operating Temperature Ranges: Commercial (0°C to +70°C) and Industrial (-40°C to +85°C)
  16. Underwriters Laboratories® (UL) Recognized



Circuit Diagram:

Arduino & DS3231 Based Real Time Clock (RTC) & Temperature Monitor

Connect SDA and SCL pins of DS3231 with SDA & SCL pin, i.e A4 & A5 of Arduino.

To connect LCD: Connect Pin 12, 11, 5, 4, 3, 2 of Arduino with Pin 4, 6, 11, 12, 13, 14 of LCD.


Working:

To make this project work first add the library for DS3231 which is given below. After that upload the code. Once the code is uploaded the project starts working.

  • 1
  • 2
  • 3
  • 4

  • 1
  • 2
  • 3
  • 4

On the first row, Real-Time Clock will be displayed. But on the 2nd-row date, time day and temperature will be displayed each after the interval of 3 seconds.

Note: Edit the code to set the current date, time, and date on the line below.

C++
1
2
3
4
5
6
7
void setup()
{
rtc.begin();
lcd.begin(16,2);
rtc.setDOW(SUNDAY);     // Set Day-of-Week
rtc.setTime(18, 50, 35);     // Set the time to 12:00:00 (24hr format)
rtc.setDate(16, 12, 2018);   // Day, Month, Year



Source Code:

Download DS3231 Library file from here: DS3231 Library Dowload

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <DS3231.h>
#include <LiquidCrystal.h>
DS3231 rtc(SDA, SCL);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 
void setup() {
rtc.begin();
lcd.begin(16,2);
rtc.setDOW(SUNDAY); // Set Day-of-Week
rtc.setTime(18, 50, 35); // Set the time to 12:00:00 (24hr format)
rtc.setDate(16, 12, 2018); // Day, Month, Year
}
 
void loop() {
lcd.setCursor(0,0);
lcd.print("Real Time Clock ");
 
lcd.setCursor(0,1);
lcd.print("Time: ");
lcd.print(rtc.getTimeStr());
delay(3000);
 
lcd.setCursor(0,1);
lcd.print("Date: ");
lcd.print(rtc.getDateStr());
delay(3000);
 
lcd.setCursor(0,1);
lcd.print("Day: ");
lcd.print(rtc.getDOWStr());
lcd.print(" ");
delay(3000);
 
lcd.setCursor(0,1);
lcd.print("Temp: ");
lcd.print(rtc.getTemp());
lcd.print(" C");
lcd.print(" ");
delay(3000);
}


Video Preview & Explanation:

DS3231 Based Real Time Clock (RTC) & Temperature Monitor Using Arduino
Watch this video on YouTube.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleInterfacing SHT3x Humidity & Temperature Sensor with Arduino
Next Article Getting Started with STM32 Microcontroller : Blinking of LED

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
View 3 Comments

3 Comments

  1. jagadeesh kalapala on October 26, 2021 2:55 PM

    is there any special feature we can add to this project

    Reply
  2. Dominik on April 28, 2022 3:54 PM

    It doesn’t work. I’ve got a lot of errors connected with things insite library DS3231.. mostly wrong functions names. Do dupy!

    Reply
  3. Patrick on August 28, 2023 3:55 AM

    Sketch does not compile so I can’t make this project. Very dissapointing

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

July 6, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • C1001 60 GHz mmWave Sensor with ESP32 for Sleep, Fall, Life Detection
    C1001 60 GHz mmWave Sensor with ESP32 for Sleep, Fall, Life Detection
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • IoT Based Drinking Water Quality Monitoring with ESP32
    IoT Based Drinking Water Quality Monitoring with ESP32
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.