How to Connect a DS3231 to NodeMCU V3

To connect a DS3231 RTC module to an ESP8266-based NodeMCU V3 development board, we use the I2C interface. The default I2C interface pins of NodeMCU V3 board are the pins D1 (SCL) and D2 (SDA).

NodeMCU V3 --> DS3231 RTC
        D1 --> SCL
        D2 --> SDA
       3V3 --> VCC
       GND --> GND

You may consult the article NodeMCU V3 Pinout and Configuration to verify the pin layout of a NodeMCU V3 development board.

Image showing connection of ds3231 to a nodemcu v3 development board
DS3231 RTC Module Connected to NodeMCU V3 ESP8266 Board
Zoomed view of the connection between ds3231 rtc module to a nodemcu v3 development board
DS3231 RTC Module Connected to NodeMCU V3 ESP8266 Board (Zoom View)

Programming with Arduino IDE

// Arduino DS3232RTC Library
// https://github.com/JChristensen/DS3232RTC
// Copyright (C) 2019 by Jack Christensen and licensed under
// GNU GPL v3.0, https://www.gnu.org/licenses/gpl.html
//
// Simple example sketch that should work on any architecture.
// For the AVR architecture, instantiating the DS3232RTC object
// is redundant, but this is only for testing purposes.
//
// Jack Christensen 24Sep2019

#include <DS3232RTC.h>      // https://github.com/JChristensen/DS3232RTC
DS3232RTC myRTC;

void setup()
{
    Serial.begin(115200);
    myRTC.begin();
}

void loop()
{
    display();
    delay(10000);
}

// display time, date, temperature
void display()
{
    char buf[40];
    time_t t = myRTC.get();
    float celsius = myRTC.temperature() / 4.0;
    float fahrenheit = celsius * 9.0 / 5.0 + 32.0;
    sprintf(buf, "%.2d:%.2d:%.2d %.2d%s%d ",
        hour(t), minute(t), second(t), day(t), monthShortStr(month(t)), year(t));
    Serial.print(buf);
    Serial.print(celsius);
    Serial.print("C ");
    Serial.print(fahrenheit);
    Serial.println("F");
}

Related Articles on How to Connect a DS3231 to NodeMCU V3

Arduino Reference and Resources
How to Set up Arduino IDE for ESP8266 Programming
NodeMCU V3 ESP8266 Pinout and Configuration
How to Test NodeMCU V3 Using Esptool
How to Install Arduino IDE on Windows 10
How to Save and Restore ESP8266 and ESP32 Firmware
NodeMCU ESP-32S Pin Configuration

References on How to Connect a DS3231 to NodeMCU V3

NodeMCU on Wikipedia
Maxim DS3231 RTC

Leave a comment

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