TM1637 4-Digit Display Clock Arduino Project

TM1637 4-Digit Display Clock Arduino Project

This project shows you how to make a digital clock using a TM1637 4-digit 7-segment display with Arduino. This display is excellent for showing time. For more details, watch the video below or read the written tutorial below.

TM1637 4-Digit Display Arduino Clock Using RTC DS3231

Components for the TM1637 4-Digit Display Clock

Arduino Uno× 1Amazon
TM1637 4-digit 7-segment display× 1Amazon
DS3231× 1Amazon
Breadboard× 1Amazon
Jumper wires kit× 1Amazon
USB cable type A/B× 1Amazon


Arduino IDE

TM1637 4-Digit 7-Segment Display

The module is a special LED (light-emitting diode display) drive control circuit with a keyboard scan interface that is internally integrated with MCU digital interface, data latch, LED high-pressure drive, and keyboard scan.

TM1637 4-Digit 7-Segment Display Specifications

Operating  voltage3.3V – 5.5V
Operating current consumption80mA
Operating temperature-10ºC to +80ºC
Display dimensions30 x 14 mm (0.36″ digits)
Overall dimensions42 x 24 x 12 mm
CostCheck price

This IC is made by Titan Micro Electronics. For more information, you can check out the datasheet below:


The DS3231 is a low-cost, very precise I2C real-time clock (RTC) with a TCXO and crystal integrated compensating temperature. The device has a battery input which keeps the time when the device’s key energy is disrupted. The incorporation of the crystal resonator increases the device’s long-term precision and lowers component count in a production line. The DS3231 is sold in a 16-pin 300-mile SO kit and is available in commercial or industrial temperature ranges.

  • RTC counts seconds, minutes, hours, and year
  • Accuracy: +2ppm to -2ppm for 0ºC to +40ºC , +3.5ppm to -3.5ppm for -40ºC to +85ºC
  • Digital temperature sensor with ±3ºC accuracy
  • Two Time-of-day alarms
  • Programmable square-wave output
  • 400Khz I2C interface
  • Low power consumption
  • Automatic power failure battery switch circuitry
  • CR2032 battery backup with two to three-year life

DS3231 Specifications

Operating  voltage2.3V – 5.5V
Operating current consumption70 – 150 µA
Operating temperature40°C to +85°C
CostCheck price

The DS3231 IC is made by Maxim Integrated. For more information, you can check out the DS3231 datasheet below:

TM1637 4-Digit Display Clock Circuit Schematics

TM1637 4-Digit Display Clock Circuit Schematics
TM1637 4-Digit Display Clock Circuit Schematics

SDA and SCL Connections

Board I2C / TWI pins
Uno, Ethernet A4 (SDA), A5 (SCL)
Mega2560 20 (SDA), 21 (SCL)
Leonardo 2 (SDA), 3 (SCL)
Due 20 (SDA), 21 (SCL), SDA1SCL1

TM1637 Display Connections

TM1637 4-Digit DisplayArduino
CLKDigital pin 8
DIODigital pin 9

DS3231 RTC Connections


Libraries for the TM1637 4-Digit Display Clock

To install the libraries, you can download them from here. Next, go to Sketch > Include Library > Add .ZIP Library… in the Arduino IDE.

TM1637 4-Digit Display Clock Source Code

By clicking the button in the top right corner of the code field, you can copy the code. Copy and paste it into Arduino IDE. 

/* */
/* Degital 24 hour time format clock by Arduino, TM1637 4 digit 7 segment display and DS32321 RTC.*/

// Add libraries: RTClib and TM1637
#include "RTClib.h"
#include <TM1637Display.h>

// Define the connections pins for TM1637 4 digit 7 segment display
#define CLK 8
#define DIO 9

// Create rtc and display object
RTC_DS3231 rtc;
TM1637Display display = TM1637Display(CLK, DIO);

void setup() {
  // Begin serial communication at a baud rate of 9600
  // Wait for console opening

  // Check if RTC is connected correctly
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  // Check if the RTC lost power and if so, set the time:
  if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
    // The following line sets the RTC to the date & time this sketch was compiled:
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));

  // Set the display brightness (0-7):
  // Clear the display:

void loop() {
  // Get current date and time
  DateTime now =;

  // Create time format to display:
  int displaytime = (now.hour() * 100) + now.minute();

  // Print displaytime to the Serial Monitor

  // Display the current time in 24 hour format with leading zeros enabled and a center colon:
  display.showNumberDecEx(displaytime, 0b11100000, true);

  // Remove the following lines of code if   you want a static instead of a blinking center colon:

  display.showNumberDec(displaytime, true); // Prints displaytime without center colon.


Leave a Reply