Arduino DS3231 Interfacing Example

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.

DS3231 rtc arduino

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.

DS3231 rtc module
DS3231 rtc module

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 UnoBUY LINK
DS3231 RTC ModuleBUY LINK
BreadboardBUY LINK
Jumper WiresBUY LINK
Arduino Uno CableBUY LINK
DS3231 rtc arduino component

Circuit Diagram of RTC Module And Arduino Uno:

Arduino DS3231 Example Circuit Diagram

Circuit Table:

Arduino UNODS3231 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.

DS3231 rtc module serial monitor
DS3231 rtc module serial monitor
DS3231 rtc arduino

Video sample

Related Posts

Voltage sensor with Arduino

Interface Voltage sensor with Arduino Uno | Voltage Measure using Arduino

Hey guys. welcome back to the Techatronic. In this tutorial we are going to interface a very useful and unique sensor which is Voltage sensor. Interface Voltage…

water logging

Water Logging Solution Science Project | Water drainage idea

Hey guys welcome back to the Techatronic. So today we have a very good science project which can help us in the rainy days. In rainy season…

Air Pressure sensor HX710B with arduino

Air Pressure sensor HX710B with arduino

Hey guys, welcome back to the techatronic. In this article we are going to explain how can we interface Air Pressure sensor HX710B with Arduino. all the…

Sun Tracking Solar Panel using an Arduino

Sun Tracking Solar Panel using an Arduino

An energy source that is obtained from nature without harming the environment is called renewable energy. Solar energy is one of the most well-known forms of renewable…

Home Security Alarm

Home Security Alarm using Arduino

Hello Guys, Welcome back to Techatronic. Today we are going to build an another interesting project which is called ‘Home Security Alarm’ with the help of Arduino…

Prevention Of Railway Accidents

Prevention Of Railway Accidents Using Arduino Uno

Hey guys, welcome to TechaTronic. Before moving forward in this “Prevention Of Railway Accidents” project lets first discuss about the history of railways. Railways are very common…

Leave a Reply

Your email address will not be published. Required fields are marked *