Arduino Nano ESP32 - TM1637 4-Digit 7-Segment Display

Welcome to this hands-on workshop where we connect a TM1637 4-digit 7-segment display to an Arduino Nano ESP32. The Nano ESP32 is built around the ESP32-S3 chip, giving you Wi-Fi, Bluetooth Low Energy, and dual-core processing power - all packed into the familiar Nano form factor with a USB-C connector. The TM1637 module runs on 3.3V, so it pairs directly with the Nano ESP32 without any level shifting.

In this workshop you will:

Arduino Nano ESP32 TM1637 4-Digit 7-Segment Display

Hardware Preparation

1×Arduino Nano ESP32
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
1×Breadboard
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano ESP32

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 specialized LED driver IC that handles the multiplexing of four 7-segment digits on its own. Data transfer uses a 2-wire serial protocol through CLK and DIO pins. The chip stores display content in internal registers, so whatever you send to it stays on screen without the microcontroller having to refresh it continuously.

Module capabilities:

  • 4 digits, each with 7 segments and a decimal point
  • Colon separator between digit 1 and digit 2
  • 8 brightness levels controlled by software
  • 2-wire interface supporting 3.3V and 5V logic
  • Nonvolatile display memory
Function Pin
CLK Clock signal input
DIO Data input/output
VCC Power supply (3.3V or 5V)
GND Ground

Connect CLK and DIO to any available digital pins on the Nano ESP32. The examples use D2 and D4.

Wiring Diagram

Connect the TM1637 module to the Arduino Nano ESP32:

  • CLK to D9
  • DIO to D10
  • VCC to 3.3V
  • GND to GND
The wiring diagram between Arduino Nano ESP32 and TM1637 4-Digit 7-Segment Display

This image is created using Fritzing. Click to enlarge image

Library Setup

  1. Plug the Arduino Nano ESP32 into your computer through its USB-C port.
  2. Open Arduino IDE. Pick Arduino Nano ESP32 from the board list and select the right port.
  3. Click the Libraries icon on the left sidebar.
  4. Type "DIYables_4Digit7Segment_TM1637" in the search field. Find the DIYables entry.
  5. Hit Install.
Arduino TM1637 4-Digit 7-Segment Display library

Self-contained library - nothing else to install.

Starter Sketch

The minimum code needed to get going with the DIYables_4Digit7Segment_TM1637 library:

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

Create the display object with the pin numbers, call begin(), and start writing data. The Nano ESP32 uses Dx pin labels which map to the ESP32-S3 GPIO numbers internally.

Workshop - Display Integer Numbers

Put the display through its paces with various integer values - positive, negative, and zero-padded.

/* * This Arduino Nano ESP32 code was developed by newbiely.com * * This Arduino Nano ESP32 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-esp32/arduino-nano-esp32-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 D9 #define DIO_PIN D10 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); void setup() { Serial.begin(9600); 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); }

Hands-On

  • Wire the TM1637 module to the Nano ESP32 as shown in the wiring diagram.
  • Connect the Nano ESP32 to your computer via USB-C.
  • In Arduino IDE, choose the board and port, paste the code, and click Upload.
  • Open the Serial Monitor to observe the results.

The display cycles through 0, 42, 1234, -5, -123, 9999, and then shows "0042" with zero-padding.

Method Reference

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()

Workshop - Display Text and Temperature

Put text strings and temperature readings on the display, including the degree symbol.

/* * This Arduino Nano ESP32 code was developed by newbiely.com * * This Arduino Nano ESP32 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-esp32/arduino-nano-esp32-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 D9 #define DIO_PIN D10 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); void setup() { Serial.begin(9600); 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); }

Hands-On

  • Wire the module and upload the sketch.
  • Open the Serial Monitor.

The display shows "HELP", "Hi", "COOL", "done", then "25°C" and "72°F".

Method Reference

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

Workshop - Display Time with Blinking Colon

Set up a clock-style display with the colon blinking at 500ms intervals.

/* * This Arduino Nano ESP32 code was developed by newbiely.com * * This Arduino Nano ESP32 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-esp32/arduino-nano-esp32-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 D9 #define DIO_PIN D10 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); int hours = 12; int minutes = 30; bool colonOn = true; void setup() { Serial.begin(9600); 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; }

Hands-On

  • Upload and watch "12:30" with the colon toggling on and off.

Method Reference

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)

Workshop - Individual Digit Control

Set each digit position independently using numbers, characters, and the colon.

/* * This Arduino Nano ESP32 code was developed by newbiely.com * * This Arduino Nano ESP32 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-esp32/arduino-nano-esp32-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 D9 #define DIO_PIN D10 DIYables_4Digit7Segment_TM1637 display(CLK_PIN, DIO_PIN); void setup() { Serial.begin(9600); 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); }

Hands-On

  • Upload and observe the different digit and character combinations on the display.

Method Reference

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)

Troubleshoot

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

Platform Support

The library is built entirely on Arduino standard APIs and supports all Arduino-compatible platforms (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!