Site icon Iotguider

Learn interfacing DS3231 RTC Module in Arduino

Learn using the DS3231 RTC Module in Arduino. Currently, we are using a DS3231 RTC Module and Arduino Uno board. Setup and display the time of DS3231 on Serial Monitor.

First, let’s start with the basics of the DS3231 Real Time Clock Module.

Operating Voltage: 3.3 – 5V
Current: 15mA
Accuracy: ±2ppm at 0°C to +40°C and ±3.5ppm at -40°C to +85°C
Digital Temp Sensor Output: ±3°C Accuracy
Alarms: Two times of a day
Battery Backup for continuous timekeeping

Integrating Adafruit RTC Library in Arduino IDE.
  1. Download Adafruit RTC Library Zip file from below given link
  2. Go to Sketch > Include library > Add .zip Library
  3. Select the downloaded zip file
  4. If the Library is successfully added, Arduino IDE will show “Library added to your libraries. Check Include Library menu” on the status bar.

For more information about Adafruit RTClib, Click here.

Step 1: Required Components

DS3231 RTC module x 1
Arduino Uno Board x 1
Jumper Wires

Step 2: Circuit Time

Make a circuit as per the given diagram. In the Real-Time Clock, there are six pins available. We will be using only four pins. Connect the pins as below given.

VCC to 5V
GND to Ground
SDA to Arduino SDA pin
SCL to Arduino SCL pin.




Step 3: Code Time

This is code for DS3231 RTC Module in Arduino. First, we include a necessary library for the Real-Time Clock. Then we create an array for a day of the week. In setup, the Serial Monitor is begun at 9600 Baud and Date and Time are set according to system time if the time of RTC is not set. In the loop, we fetch current date and time from Real-Time Clock and it is displayed in the serial monitor. To reset Real Time Clock, remove all wires from Arduino and also battery from Real Time Clock for 10 seconds. Then reassemble the circuit and upload the program again.

Step 4: Upload the code to Arduino

Set components as per the Circuit Diagram and upload the code to the Arduino UNO Board. DS3231 Real Time Clock will provide time to Arduino and it will display in Serial Monitor. The screenshot of the output of the Serial Monitor is as below.

Learn more information about uploading code to Arduino Uno.

Note: if you want to set your customized time to DS3231 use “rtc.adjust(DateTime(year, month, date, hour, minute, second));”

Exit mobile version