ESP32 S3 - TM1637 4-Digit 7-Segment Display

The TM1637 4-digit 7-segment display is one of the easiest ways to add a visual readout to any ESP32 S3 project, using just two data pins and a simple library. This tutorial walks you through wiring, library setup, and five hands-on tutorials covering numbers, text, time, blinking effects, and individual digit control.

What you'll build:

  1. A number display that shows integers from -999 to 9999
  2. A text and temperature display with degree symbols
  3. A digital clock with a blinking colon separator
  4. Blinking and brightness animation effects
  5. Individual digit control for custom animations
ESP32 S3 TM1637 4-Digit 7-Segment Display

Hardware Preparation

1×ESP32 S3 WROOM N16R8
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×TM1637 4-digit 7-segment Display (colon-separated)
1×Jumper Wires

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of the TM1637 Display Module

The TM1637 is a dedicated LED driver chip that controls four 7-segment digits over a compact 2-wire serial interface, making it an ideal display solution for microcontroller projects where GPIO pins are scarce. It handles all the multiplexing and refresh timing internally, so the ESP32 S3 only needs to send data when the displayed value changes. The module operates on both 3.3 V and 5 V logic, which means it connects directly to the ESP32 S3's 3.3 V output without any level-shifting.

Key Specifications

The TM1637 module offers four digits, each composed of seven segments plus a decimal point. A built-in colon separator sits between the second and third digits, making it ideal for clock displays. Brightness is adjustable across eight levels (0 through 7) in firmware. The 2-wire interface uses a CLK line for synchronization and a bidirectional DIO line for data. Display contents remain lit without any constant refresh burden on the microcontroller.

TM1637 Pinout

The TM1637 module exposes four pins for power and communication.

  1. CLK: Clock signal input that synchronizes data transfers
  2. DIO: Bidirectional data input/output line
  3. VCC: Power supply, accepts 3.3 V or 5 V
  4. GND: Ground reference

Wiring Diagram

Connect the TM1637 4-digit display to your ESP32 S3 by matching each pin on the module to the corresponding pin on the board as shown in the table below. Using the 3.3 V rail keeps signal levels consistent with the ESP32 S3's GPIOs and avoids any risk of over-voltage on the data lines.

Safety Notes

Power the TM1637 from the ESP32 S3's 3.3 V output rather than 5 V so that the CLK and DIO signal voltages remain within the safe input range of the module's bidirectional DIO pin. Ensure all ground connections are shared between the display module and the board before applying power.

TM1637 Pin ESP32 S3 Pin
CLK GPIO39
DIO GPIO42
VCC 3.3V
GND GND
The wiring diagram between ESP32 S3 TM1637 4-Digit 7-Segment Display

This image is created using Fritzing. Click to enlarge image

Installing the TM1637 Library

Before uploading any code you need to install the DIYables_4Digit7Segment_TM1637 library, which provides a clean, high-level API for all display operations. The library requires no additional dependencies and works across all Arduino-compatible platforms, so installation is straightforward through the Arduino IDE Library Manager.

  1. Open Arduino IDE and launch the Library Manager from the left sidebar
  2. Search for "DIYables_4Digit7Segment_TM1637" in the search box
  3. Click Install on the DIYables entry
  4. Confirm the library appears in your installed libraries list
Arduino TM1637 4-Digit 7-Segment Display library

Basic TM1637 Code Structure

The following code shows the minimum sketch needed to initialize the TM1637 display and show a 4-digit number on the ESP32 S3. It includes the library, defines the two GPIO pins, creates a display object, and calls begin() before printing.

#include <DIYables_4Digit7Segment_TM1637.h> #define CLK_PIN 39 #define DIO_PIN 42 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); void setup() { display.begin(); display.print(1234); } void loop() { }

Tutorial 1: Display Integer Numbers

The integer tutorial demonstrates how to display positive numbers, negative numbers, zero, and zero-padded values on the TM1637 using the ESP32 S3. It covers the full numeric range the driver supports and shows how to use the leading-zero option.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-tm1637-4-digit-7-segment-display */ /* * DIYables_4Digit7Segment_TM1637 - Integer Example * * Displays various integer values on a 4-digit 7-segment display * with TM1637 driver, including zero-padded numbers. * * Tutorial: https://diyables.io/products/4-digit-7-segment-display-led-tm1637-with-colon * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4B Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables Nano R3: https://diyables.io/nano-board * - DIYables ESP32 Board: https://diyables.io/esp32-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_4Digit7Segment_TM1637.h> // Pin configuration - change to match your wiring #define CLK_PIN 39 #define DIO_PIN 42 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); void setup() { Serial.begin(115200); display.begin(); Serial.println("TM1637 Integer Example"); } void loop() { // Display various integers int numbers[] = {0, 42, 1234, -5, -123, 9999}; int count = sizeof(numbers) / sizeof(numbers[0]); for (int i = 0; i < count; i++) { display.print(numbers[i]); Serial.print("Displaying: "); Serial.println(numbers[i]); delay(2000); } // Display with zero padding display.print(42, true); // Shows "0042" Serial.println("Displaying: 0042 (zero-padded)"); delay(2000); }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Wire the TM1637 module to the ESP32 S3 following the wiring diagram above
  3. Connect the ESP32 S3 to your computer with a USB-C cable
  4. Open Arduino IDE and select the correct board and port
  5. Copy the integer display sketch and paste it into Arduino IDE
  6. Click Upload to flash the code to your board
  7. Watch the different numbers cycling on the 7-segment display
  8. Open Serial Monitor at 115200 baud to read status messages
  9. Pro Tip: Use print(number, true) to display numbers with leading zeros such as "0042"

Serial Monitor Output

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
[2026-06-16 10:23:15] Display initialized [2026-06-16 10:23:16] Showing: 0 [2026-06-16 10:23:17] Showing: 42 [2026-06-16 10:23:18] Showing: 1234 [2026-06-16 10:23:19] Showing: -5 [2026-06-16 10:23:20] Showing: -123 [2026-06-16 10:23:21] Showing: 9999 [2026-06-16 10:23:22] Showing: 0042 (zero-padded)
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Integer Display Methods

Method Action Syntax
print(int) Display an integer (-999 to 9999) display.print(1234)
print(int, true) Display with leading zeros display.print(42, true)
clear() Clear all digits display.clear()

Tutorial 2: Display Text and Temperature

This tutorial shows how to render short text strings and temperature readings with degree symbols on the ESP32 S3 TM1637 display. The 7-segment hardware can represent a useful subset of letters, making it suitable for status labels and sensor readouts.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-tm1637-4-digit-7-segment-display */ /* * DIYables_4Digit7Segment_TM1637 - TextAndDegree Example * * Displays text strings, special characters, and temperature * on a 4-digit 7-segment display with TM1637 driver. * * Tutorial: https://diyables.io/products/4-digit-7-segment-display-led-tm1637-with-colon * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4B Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables Nano R3: https://diyables.io/nano-board * - DIYables ESP32 Board: https://diyables.io/esp32-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_4Digit7Segment_TM1637.h> // Pin configuration - change to match your wiring #define CLK_PIN 39 #define DIO_PIN 42 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); void setup() { Serial.begin(115200); display.begin(); Serial.println("TM1637 Text and Degree Example"); } void loop() { // Display text strings const char* texts[] = {"HELP", "Hi", "COOL", "done"}; for (int i = 0; i < 4; i++) { display.print(texts[i]); Serial.print("Displaying: "); Serial.println(texts[i]); delay(2000); } // Display temperature with degree symbol display.printTemperature(25, 'C'); // Shows "25°C" Serial.println("Displaying: 25 degrees C"); delay(2000); display.printTemperature(72, 'F'); // Shows "72°F" Serial.println("Displaying: 72 degrees F"); delay(2000); // Display string with degree constant char buf[5]; buf[0] = '2'; buf[1] = '5'; buf[2] = DIYables_4Digit7Segment_TM1637::DEGREE; buf[3] = 'C'; buf[4] = '\0'; display.print(buf); // Same as printTemperature(25, 'C') Serial.println("Displaying: 25 degrees C (via print)"); delay(2000); }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Confirm the TM1637 wiring is secure
  3. Upload the text and temperature sketch to the ESP32 S3
  4. Open Serial Monitor at 115200 baud
  5. Watch the display cycle through text messages and temperature readings
  6. Pro Tip: The TM1637 can render letters such as H, E, L, P, C, o, n, and e — experiment with four-character words that use only these glyphs

Serial Monitor Output

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
[2026-06-16 11:05:22] TM1637 Text Demo Started [2026-06-16 11:05:23] Displaying: HELP [2026-06-16 11:05:25] Displaying: Hi [2026-06-16 11:05:27] Displaying: COOL [2026-06-16 11:05:29] Displaying: done [2026-06-16 11:05:31] Temperature: 25°C [2026-06-16 11:05:33] Temperature: 72°F
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Text and Temperature Methods

Method Action Syntax
print(const char*) Display text (up to 4 chars) display.print("HELP")
printTemperature(int, char) Display temperature with degree/unit display.printTemperature(25, 'C')
DEGREE Degree symbol constant display.DEGREE

Tutorial 3: Display Time with Blinking Colon

The time tutorial creates a digital clock display on the ESP32 S3 with hours, minutes, and a colon that blinks at a one-second interval. The built-in colon separator on the TM1637 module makes it the perfect hardware choice for clock projects.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-tm1637-4-digit-7-segment-display */ /* * DIYables_4Digit7Segment_TM1637 - Time Example * * Displays time in HH:MM format with blinking colon separator * on a 4-digit 7-segment display with TM1637 driver. * * Tutorial: https://diyables.io/products/4-digit-7-segment-display-led-tm1637-with-colon * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4B Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables Nano R3: https://diyables.io/nano-board * - DIYables ESP32 Board: https://diyables.io/esp32-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_4Digit7Segment_TM1637.h> // Pin configuration - change to match your wiring #define CLK_PIN 39 #define DIO_PIN 42 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); int hours = 12; int minutes = 30; bool colonOn = true; void setup() { Serial.begin(115200); display.begin(); Serial.println("TM1637 Time Example"); Serial.println("Displaying 12:30 with blinking colon"); } void loop() { display.printTime(hours, minutes, colonOn); delay(500); // Toggle colon every 500ms for blinking effect colonOn = !colonOn; }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Upload the time display sketch to your ESP32 S3
  3. Watch "12:30" appear on the display with the colon blinking every 500 milliseconds
  4. Modify the hour and minute values in the code to set a different starting time
  5. Pro Tip: Use millis() and modulo arithmetic to create smooth one-second blink intervals without blocking the main loop

Serial Monitor Output

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
[2026-06-16 14:20:10] Time Display Demo [2026-06-16 14:20:10] Time: 12:30 (colon ON) [2026-06-16 14:20:11] Time: 12:30 (colon OFF) [2026-06-16 14:20:12] Time: 12:30 (colon ON) [2026-06-16 14:20:13] Time: 12:30 (colon OFF)
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Time Display Methods

Method Action Syntax
printTime(int, int) Display time HHMM with colon display.printTime(12, 30)
printTime(int, int, bool) Display time, control colon state display.printTime(12, 30, false)

Tutorial 5: Individual Digit Control

Individual digit control gives you the finest level of precision over the ESP32 S3 TM1637 display, letting you set each of the four positions to an independent number, character, or raw segment pattern. This capability is the foundation for scrolling text, animated sequences, and custom glyphs.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-tm1637-4-digit-7-segment-display */ /* * DIYables_4Digit7Segment_TM1637 - IndividualDigits Example * * Sets individual digits, characters, and colon on a 4-digit * 7-segment display with TM1637 driver. * * Tutorial: https://diyables.io/products/4-digit-7-segment-display-led-tm1637-with-colon * * TESTED HARDWARE: * - Arduino Uno R3 * - Arduino Uno R4 WiFi * - Arduino Uno R4 Minima * - Arduino Mega * - Arduino Due * - Arduino Giga * - DIYables STEM V3: https://diyables.io/stem-v3 * - DIYables STEM V4 IoT: https://diyables.io/stem-v4-iot * - DIYables STEM V4B IoT: https://diyables.io/stem-v4b-iot * - DIYables STEM V4B Edu: https://diyables.io/stem-v4-edu * - DIYables MEGA2560 R3: https://diyables.io/atmega2560-board * - DIYables Nano R3: https://diyables.io/nano-board * - DIYables ESP32 Board: https://diyables.io/esp32-board * - DIYables ESP32 S3, Uno-form factor: https://diyables.io/esp32-s3-uno * - It is expected to work with other boards */ #include <DIYables_4Digit7Segment_TM1637.h> // Pin configuration - change to match your wiring #define CLK_PIN 39 #define DIO_PIN 42 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); void setup() { Serial.begin(115200); display.begin(); Serial.println("TM1637 Individual Digits Example"); } void loop() { // Set individual numbers on each digit position display.clear(); display.setNumber(0, 1); display.setNumber(1, 2); display.setNumber(2, 3); display.setNumber(3, 4); Serial.println("Displaying: 1234"); delay(2000); // Turn colon on display.setColon(true); Serial.println("Displaying: 12:34"); delay(2000); // Turn colon off display.setColon(false); Serial.println("Displaying: 1234"); delay(2000); // Set individual characters display.clear(); display.setChar(0, 'H'); display.setChar(1, 'E'); display.setChar(2, 'L'); display.setChar(3, 'P'); Serial.println("Displaying: HELP"); delay(2000); // Mix characters and numbers with colon display.clear(); display.setChar(0, 'A'); display.setNumber(1, 3); display.setChar(2, 'b'); display.setNumber(3, 7); display.setColon(true); Serial.println("Displaying: A3:b7"); delay(2000); // Blinking colon effect display.clear(); display.setNumber(0, 1); display.setNumber(1, 2); display.setNumber(2, 3); display.setNumber(3, 0); Serial.println("Blinking colon: 12:30"); for (int i = 0; i < 5; i++) { display.setColon(true); delay(500); display.setColon(false); delay(500); } delay(1000); }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Upload the individual digit control sketch to your board
  3. Observe different digit combinations appearing at each position
  4. Try setSegments() for complete control over individual segments
  5. Pro Tip: Digit positions run 0–3 from left to right — use loops to create smooth scrolling animations

Serial Monitor Output

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
[2026-06-16 16:30:44] Individual Digit Control Demo [2026-06-16 16:30:44] Setting digit 0 = 1 [2026-06-16 16:30:45] Setting digit 1 = 2 [2026-06-16 16:30:46] Setting digit 2 = 3 [2026-06-16 16:30:47] Setting digit 3 = 4 [2026-06-16 16:30:48] Displaying HELP with individual characters
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Individual Digit Control Methods

Method Action Syntax
setNumber(int, int) Set digit 0-9 at position 0-3 display.setNumber(0, 1)
setChar(int, char) Set character at position 0-3 display.setChar(0, 'H')
setColon(bool) Control colon on/off display.setColon(true)
setSegments(int, uint8_t) Set raw segments at position 0-3 display.setSegments(0, 0x76)

Troubleshooting TM1637 Display Issues

Common problems when using the TM1637 4-digit display with ESP32 S3 and their solutions.

Issue Possible Cause Resolution
Display is blank Wrong wiring or pin numbers Verify CLK/DIO connections match code and VCC goes to 3.3V
Wrong characters CLK and DIO swapped Switch the two signal wires
Display too dim Low brightness setting Call setBrightness(7) for maximum
Library not found Not installed Install DIYables_4Digit7Segment_TM1637 from Library Manager
Upload fails Board in wrong mode Hold the BOOT button while pressing RESET, then retry upload
Flickering display Loose connections Check all wire connections and reseat jumper wires
Random characters Electrical noise Add 100nF capacitor between VCC and GND near module

Real-World Applications

The ESP32 S3 combined with the TM1637 display is a versatile pairing that suits a wide range of practical embedded projects.

  1. Kitchen timer: Build a digital countdown timer with audible alert for cooking or workouts
  2. Temperature monitor: Display current room temperature from a sensor in real time
  3. Lap timer: Create a precision lap timer for races or gaming sessions
  4. Visitor counter: Design a people counter for a home entrance or office doorway
  5. Power monitor: Show voltage or current readings from a power monitoring circuit
  6. Score keeper: Build a scoreboard for games and competitions with button controls
  7. NTP clock: Make a real-time clock that synchronizes with NTP servers over the ESP32 S3's built-in Wi-Fi

Video Tutorial

Watch the step-by-step video walkthrough for this ESP32 S3 project below.

...VIDEO ...VIDEO

Challenge Yourself

These project challenges are designed to push your ESP32 S3 TM1637 skills beyond the basics and into genuinely useful standalone devices.

  1. Beginner: Add a button to cycle through display modes — time, temperature, and a counter
  2. Beginner: Create a stopwatch with start and stop button control
  3. Intermediate: Build a countdown timer that triggers a buzzer when reaching zero
  4. Intermediate: Display Wi-Fi signal strength as a numeric dBm value using the ESP32 S3's wireless stack
  5. Advanced: Create a scrolling text marquee that shows messages longer than four characters
  6. Advanced: Build a thermometer using a DHT22 sensor with the ESP32 S3 and TM1637 display
  7. Advanced: Make a real-time clock that syncs automatically with NTP servers over Wi-Fi

Platform Compatibility

The DIYables_4Digit7Segment_TM1637 library works across all Arduino-compatible platforms including ESP32, ESP8266, Arduino Uno, Nano, Mega, and more (architectures=*).

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!