Part

Four-digit display, TM1637

Four digits and a colon on two wires. It looks like I2C and is not: no address, and bits go the other way around.

See every part
  • 4 pins
  • In 11 projects
  • In 5 lessons
Drawn live by the editor's own code, at the size you see it.
At a glance

The Four-digit display, TM1637 in brief

What it is, and where it sits on the bench.

The TM1637 is the driver on the red four-digit seven-segment clock module with a colon. Its four pins are CLK, DIO, VCC and GND, it runs from 3.3 to 5.5 V, and the board has 10 k pull-ups on both lines, so any two digital pins on an Uno or an ESP32 will do. It looks like I2C and is not: there is no address, so two modules on one pair of wires show the same thing, and bytes go least significant bit first, so Wire cannot drive it. A driver sends 0x40, then 0xC0 and four segment bytes, then 0x88 plus a brightness, and Mokxi decodes all of it from the pin edges, with the acknowledge on the ninth clock. Bit 7 of the second digit is the colon and does nothing on the other digits, which is why showNumberDecEx() takes 0b01000000 for it. The eight brightness levels are the datasheet’s pulse widths, 1, 2, 4, 10, 11, 12, 13 and 14 sixteenths, so level 3 is a big jump. The key scan reads 0xFF. The 800 Hz multiplexing, the 250 kHz clock limit and test mode are not modeled.

Family
Displays
Pins
4
Pins

4 pins

Named as the editor names them, so a wire lands where you expect it.

  • CLK
  • DIO
  • VCC
  • GND
How to use it

How to use the TM1637 display with an Arduino

Four wires: CLK to A0, DIO to A1, VCC to 5 V and GND to GND. Any two pins work, because the TM1637 is not I2C: it has no address and sends bytes least significant bit first, so it never goes on the Wire pins and Wire cannot talk to it. TM1637Display bit-bangs it on the two pins you give the constructor.

The Pomodoro timer counts down with showNumberDecEx(mmss, 0b01000000, true): the 0b01000000 lights the colon, which is wired only to the second digit, and true keeps the leading zero in 05:00. setBrightness() takes 0 to 7, and the steps are not even: 3 is a big jump from 2.

Part pin
Board pin
CLK
A0
DIO
A1
VCC
5 V
GND
GND

TM1637Display compiles on every board here, and the module runs from 3.3 V, so an ESP32 drives it on any two GPIOs.

Arduino Uno: Pomodoro timerlive0.000 s 0.00x
Hold the button
This is the simulator itself, running here. Click anything to open it in the editor.
Minutes and seconds with the colon
#include <TM1637Display.h>
TM1637Display display(A0, A1);  // CLK, DIO
void setup() {
  display.setBrightness(4);
}
void loop() {
  unsigned long s = millis() / 1000;
  int mmss = (int)((s / 60) % 60 * 100 + s % 60);
  display.showNumberDecEx(mmss, 0b01000000, true);
}
How it is modeled

What is true about the Four-digit display, TM1637, here

In its help article’s own words: what the simulation gets right, and where it stops.

The TM1637, which is not I2C

The four-digit display looks exactly like an I2C device (the same START, the same STOP, an acknowledge on a ninth clock), and it is not, in two ways that break every attempt to drive it with a Wire library:

  • There is no address. The first byte after a START is a command, so the chip answers everything on the wire. Two of them share a pair of pins and show the same thing.
  • Bytes go least significant bit first. I2C is most significant first. Get it the wrong way around and the display lights a plausible-looking set of wrong segments, which is a hard bug to see.

The three transfers a driver sends are 0x40 (write display data, auto-incrementing), 0xC0 followed by four segment bytes, and 0x80 | 0x08 | brightness. One byte a digit, bit 0 is segment A through bit 6 for G, and bit 7 is the colon, on the second digit only, which is the module's wiring rather than the chip's, and is why every library has a special case for it.

The eight brightness steps are pulse widths out of sixteen: 1, 2, 4, 10, 11, 12, 13, 14. They are not evenly spaced, which is why level 3 is such a jump.

Not modeled

Clock stretching, which none of these three chips does anyway. Arbitration between two masters. Ten-bit addressing. And the rate: the parts decode the bus from its edges and impose no timing of their own, so a driver that is too fast works here where a real device would not answer.

Arduino I2C LCD not working uses a scanner and Wire.endTransmission() to tell a wiring fault from a wrong address.

The tutorial Arduino TM1637 walks through Pomodoro timer: TM1637Display, the colon, leading zeros and a countdown timed with millis().

From Two wires, several chips, in full.

Projects

See the Four-digit display, TM1637 in a project

11 built-in projects use it. Each opens in the editor, already wired.

Boards

The boards it is shown on

Each of these 3 boards has a built-in project with the Four-digit display, TM1637 in it.

Boards

The Four-digit display, TM1637 on each board

The pins, the voltage and the code change from board to board. Each page has that board’s wiring and a circuit you can run.

Libraries

Arduino libraries for the Four-digit display, TM1637

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the Four-digit display, TM1637

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.