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

Arduino & DS3231 Based Real Time Clock (RTC) & Temperature Monitor (Last Updated On: February 25, 2019)

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

We are happy to present 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 temperature monitor to further extend this project.

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


Components Required:

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



1. Arduino board
2. DS3231 RTC Module - (Buy Online from Amazon)
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.


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.

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

#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:

Recommended For You

Ask A Question .......

Close