Learn interfacing DS3231 RTC Module in ESP8266

How to interface DS3231 RTC Module in ESP8266 WiFi Module. Currently, we are using DS3231 RTC Module and ESP8266 ESP12E WiFi Module. 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
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 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 RTC Library, Click here.

Step 1: Required Components

DS3231 RTC Module x 1
ESP8266 WiFi Module x 1
Jumper Wires

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 GPIO 4
SCL to Arduino GPIO 5

Circuit for DS3231 RTC Module in ESP8266 WiFi Module Step 3: Code Time

This is code for interfacing DS3231 RTC Module in ESP8266 WiFi Module. First, we include a necessary libraries for Real Time Clock and ESP8266 WiFi. In setup, the Serial Monitor is begun at 115200 Baud and Date and Time are set according to system time if the time of RTC is not set. Also, SSID and Password of your WiFI to connect. 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

Set components as per the Circuit Diagram and upload the code to the ESP8266 WiFi Module. DS3231 Real Time Clock will provide time to ESP8266 and it will display in Serial Monitor.

For information about uploading code to ESP8266 ESP12E Module, Click Here

Leave a Reply