Table of Contents
Introduction
Did you ever come across a project or making a project that requires the use of a DS3231 Real-Time Clock Module, and you want to use it but don’t know how?
If so,
you’ve come to the right place. In this Arduino Tutorial, we will provide you with a detailed step-by-step guide on Arduino DS3231 set time Example.
I hope it will be helpful for you. We at Techatronic have already uploaded several Arduino Tutorials and detailed project guides related to Arduino which will be useful to learn the basics and programming of Arduino.
With the use of the DS3231 RTC Module along with Arduino for a wide range of Real-time-based functionalities to our projects which can be very helpful, such as an Alarm Clock, Timer, Automatic pet feeding machine, etc.
What is DS3231 RTC Module?
The DS3231 is an RTC Module that can be used for precise timekeeping and date counting. This can be used to record anything from seconds, minutes, and hours to the date, day, month, and year (which is valid till 2100).
To send and receive data, this module uses the I²C communication interface. This also has a temperature compensated crystal oscillator (TCXO) built-in, which eliminates unstable readings caused by changes in external temperatures.
The main advantage of the DS3231 RTC Module is its onboard battery support which acts as a backup power supply when no external power is supplied.
The module consumes nearly 3µA of power in an hour, hence the battery used helps the module to run continuously for more than 5 years. Arduino rtc interface.
This module is used in a wide range of electronics including a computer motherboard, Servers, GPS, Data Loggers, etc.
How does the module work?/ Working
The RTC modules employ either a capacitor-based oscillator or an integrated quartz crystal.
that is either internal to the chip or mostly externally linked in the circuit It records the time elapsed between two oscillations in the 32kb EEPROM IC on the module.
The data stored can be accessed even if the module is turned off and back on.
Components Required :
- Arduino Uno
- DS3231 RTC Module
- Breadboard
- Jumper Wires
- USB cable to connect Arduino Uno with Computer
Circuit Diagram of RTC Module And Arduino Uno:
Circuit Table:
Arduino UNO | DS3231 RTC Module |
( +5V ) | VCC |
GND | GND |
A4 Pin ( SDA ) | SDA Pin |
A5 Pin ( SCL ) | SCL Pin |
- 5V pin of Arduino Uno to VCC of RTC Module.
- GND pin of Arduino Uno to GND of RTC Module.
- Analog Input pin A4 of Arduino Uno With SDA of RTC Module.
- Analog Input pin A5 of Arduino Uno With SCL of RTC Module.
Arduino DS3231 Example Code:
NOTE:- Before going ahead, Download RTC DS3231 Arduino Library by clicking Here and Install in your Arduino IDE.
// TECHATRONIC.COM
// RTC CIRCUIT DS3231 LIBRARY
//http://www.rinkydinkelectronics.com/library.php?id=73
#include <DS3231.h> // RTC LIBRARY
#include <Wire.h> // WIRE LIBRARY
// Init the DS3231 using the hardware interface
DS3231 rtc(SDA, SCL);
void setup()
{
// Setup Serial connection
Serial.begin(9600);
// Initialize the rtc object
rtc.begin();
// The following lines can be uncommented to set the date and time
// rtc.setDOW(FRIDAY); // Set Day-of-Week to FRIDAY
// rtc.setTime(12, 37, 0); // Set the time to 12:00:00 (24hr format)
// rtc.setDate(1, 1, 2021); // Set the date to January 1st, 2021.
}
void loop()
{
// Send Day-of-Week
Serial.print(rtc.getDOWStr());
Serial.print(" ");
// Send date
Serial.print(rtc.getDateStr());
Serial.print(" -- ");
// Send time
Serial.println(rtc.getTimeStr());
// Wait one second before repeating :)
delay (1000);
}
After uploading the code, Open Serial Monitor in Arduino IDE to view the generated output of this code. If you have any query, You can contact us.
Hai….
Your projects are very good and easy…
I want to make ” led matrix scrolling text display with clock” please post this project
Thanks we will make it soon