Learn using DS3231 RTC Module in Arduino. Currently, we are using 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 DS3231 Real Time Clock Module.
Operating Voltage: 3.3 – 5V
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.
- Download Adafruit RTC Library Zip file from below given link
- Go to Sketch > Include library > Add .zip Library
- Select the downloaded zip file
- If 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
Step 2: Circuit Time
Make a circuit as per the given diagram. In 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 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. Screenshot of the output of Serial Monitor is as below.
For information about uploading code to Arduino UNO, Click Here.
Note: if you want to set your customized time to DS3231 use “rtc.adjust(DateTime(year, month, date, hour, minute, second));”