Real time clock using NodeMCU, DS3231 and SSD1306 OLED

This NodeMCU project shows how to build a real time clock with this development board, DS3231 RTC chip and SSD1306 OLED display (128×64 Pixel).
The DS3231 RTC has a built-in temperature sensor, we could use this sensor to detect and read the temperature of the chip, the SSD1306 screen will also display this temperature.

The DS3231 uses I2C interface to communicate with the master device which is in this case the ESP8266 NodeMCU board. That means the DS3231 and the SSD1306 OLED screen share the same I2C bus. Even they share the same bus but at any time the microcontroller ‘speaks’ with 1 device only depending on the address sent. The DS3231 RTC address is 0x68 and the SSD1306 OLED address is 0x3D.
In the circuit there are two push buttons for setting time and date of the real time clock.

The SSD1306 OLED used in this project is configured to work in I2C mode, some SSD1306 OLED boards may require a small hardware modifications (to select between SPI mode or I2C mode) such as soldering, placing jumpers ….

Related Projects:
ESP8266 NodeMCU interfacing with SSD1306 OLED
ESP8266 ESP-01 Real time clock with DS3231/DS1307
Arduino real time clock with temperature monitor using DS3231 and SSD1306

ESP-12E NodeMCU with DS3231 RTC and SSD1306 OLED

Hardware Required:

  • ESP8266 NodeMCU development board
  • SSD1306 OLED display with 128×64 Pixel resolution
  • DS3231 board  —  DS3231 RTC datasheet
  • 2 x push button
  • 3V coin cell battery
  • micro USB cable (for programming and powering the circuit)
  • Breadboard
  • Jumper wires

NodeMCU + DS3231 RTC + SSD1306 OLED circuit:
The following image shows project circuit schematic diagram.

ESP8266 NodeMCU DS3231 RTC SSD1306 OLED circuit

and the second one shows fritzing circuit:

NodeMCU DS3231 RTC SSD1306 OLED fritzing

The SDA and SCL lines of the I2C bus come from GPIO4 (D2) and GPIO0 (D3) of the NodeMCU board (respectively), they are connected to SDA and SCL (SCK) pins of the SSD1306 display module. Also, they are connected to SDA and SCL pins of the DS3231 module.
Reset pin (RES) of the display module is connected to GPIO5 (D1) of the NodeMCU development board.

The two push buttons B1 and B2 are for setting time and date. Button B1 is connected to pin GPIO12 (D6) and B2 is connected to pin GPIO13 (D7) of the NodeMCU. Internal pull-ups for the two input pins are enabled in the code.

The SSD1306 display module and the DS3231 board are supplied with 3.3V that comes from the NodeMCU development board.

NodeMCU Interfacing with SSD1306 and DS18B20 code:
SSD1306 OLED and DS3231 RTC share the same I2C bus and the ESP8266 communicates only with 1 device at a time depending on the address (sent by the ESP8266), the SSD1306 address is 0x3D and the DS3231 address is 0x68.

The Arduino IDE code below uses Adafruit SSD1306 OLED driver and Adafruit GFX library. It doesn’t use any library for the DS3231 RTC.

NodeMCU + DS3231 RTC + SSD1306 OLED video:


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top