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
Components Required:
To design Arduino & DS3231 Based Real Time Clock (RTC) & Temperature Monitor, we need the following components.
- Arduino board
- DS3231 RTC Module
- 16 x 2 LCD
- 3V coin cell battery
- Breadboard
- 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.
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:
- Highly Accurate RTC Completely Manages All Timekeeping Functions
- 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 - Accuracy ±2ppm from 0°C to +40°C
- Accuracy ±3.5ppm from -40°C to +85°C
- Digital Temp Sensor Output: ±3°C Accuracy
- Register for Aging Trim
- Active-Low RST Output/Pushbutton Reset Debounce Input
- Two Time-of-Day Alarms
- Programmable Square-Wave Output Signal
- Simple Serial Interface Connects to Most Microcontrollers
- Fast (400kHz) I2C Interface
- Battery-Backup Input for Continuous Timekeeping
- Low Power Operation Extends Battery-Backup Run Time
- 3.3V Operation
- Operating Temperature Ranges: Commercial (0°C to +70°C) and Industrial (-40°C to +85°C)
- Underwriters Laboratories® (UL) Recognized
Circuit Diagram:
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.
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); } |
3 Comments
is there any special feature we can add to this project
It doesn’t work. I’ve got a lot of errors connected with things insite library DS3231.. mostly wrong functions names. Do dupy!
Sketch does not compile so I can’t make this project. Very dissapointing