Arduino real time clock with temperature monitor using DS3231 and SSD1306

In the last post I built an Arduino based real time clock using DS1307 RTC and SSD1306 OLED and in this project I’m going to show how to build a real time clock with temperature monitor using Arduino, DS3231 RTC chip and SSD1306 OLED (128×64 pixel).

The DS3231 is more accurate than the DS1307 due to its built-in temperature sensor. It also (the DS3231) keeps the time running if the main power source is down. It also uses I2C interface to communicate with the master device which is in this case the Arduino. 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 (the same address with the DS1307) 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.

Related Projects:
Arduino and DS3231 real time clock
Interfacing Arduino with SSD1306 OLED display
Arduino real time clock using DS1307 and SSD1306 OLED

Hardware Required:

  • Arduino board
  • DS3231 board  —  DS3231 RTC datasheet
  • SSD1306 OLED (I2C mode)
  • 2 x push button
  • 3V coin cell battery
  • Breadboard
  • Jumper wires

Arduino with SSD1306 OLED and DS3231 RTC circuit

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 …

In this project I used Adafruit SSD1306 OLED driver and Adafruit GFX library. Both libraries can be downloaded through Arduino IDE Library Manager of manually from the links below (after downloading, unzip the folders and place them in Arduino libraries folder, for example C:\Program Files\Arduino\libraries)
Adafruit SSD1306 OLED library   —   direct link
Adafruit GFX library                  —   direct link

Project circuit:
Project circuit diagram is shown below.

Arduino SSD1306 OLED DS3231 RTC with set buttons

(All grounded terminals are connected together)

The two push buttons B1 and B2 are for setting time and date.

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

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

The small video below shows a simple hardware circuit of the project:

and the one below shows the simulation of the project with Proteus (the simulation circuit is not the same as the hardware circuit, the hardware circuit diagram is shown above).

Proteus simulation file download (for version 8.6 or higher):
Arduino + SSD1306 OLED + DS3231

Leave a Reply

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