TM1637 display/Why this display/02. Two wires, but not I²C
Why this display · 02 of 13

Two wires, but not I²C

A clock line, a data line, a start and a stop: it looks exactly like I²C and it is not. There is no address anywhere in the protocol, which decides how you wire a second display and why a bus scan will never find the first one.

What goes down the wires

Everything the display is ever told is a byte, and every byte goes out the same way: a start, eight bits, an acknowledge from the chip, a stop.

One byte, two wires
0x40 · 0b01000000

Idle. Both wires sit high, held there by the 10 kΩ resistors on the board — nothing is driving them.

Which byte
Byte
0x40
Means
write to the display, address stepping on its own
Address
none
Two wires, no address. It looks like I²C — a clock, a data line, a start and a stop — and it is not: there is no address in the protocol at all, so nothing chooses which chip is being spoken to, and an I²C scanner will never find this display. Which is also why a second display needs a DATA pin of its own. The chip is rated to 500 kHz; the library ambles along at a bit every 300 µs, which is why an update takes about 21 ms.

Press through it once. The parts worth noticing:

Both wires idle high on their own. Your board never drives them up — it either pulls a wire down to 0 V or lets go of it, and the two 10 kΩ resistors on the board pull it back up. That is the same trick I²C uses, and it is why the board can sit next to a 3.3 V or a 5 V processor without either one fighting it.

The bits go out least significant first. I²C sends the most significant bit first. This does not. It matters the moment you start writing segment patterns by hand: bit 0 of the byte is segment A, and it is also the first bit on the wire.

The chip answers. On the ninth clock the display pulls DATA down itself to say it heard you. That amber pulse is the only thing on the wire your board did not put there.

The part that is missing

There is no address. Nowhere in any of those bytes is there anything that says which chip should pay attention.

I²C opens every exchange with an address precisely so that a dozen devices can share two wires. The TM1637 has nothing of the kind — the datasheet says so in as many words, that the protocol "is not equal to I2C bus protocol totally because there is no slave address". Every chip that can hear the wires acts on everything it hears.

Three consequences, all of them practical:

  • An I²C scan finds nothing. Not a fault. There is nothing to find.
  • It cannot share your I²C bus. SDA and SCL belong to devices that understand addressing; this display would corrupt their traffic and be corrupted by it.
  • A second display needs its own DATA pin. This is the one that shapes real projects, and more than one display is entirely about it.

What it costs in time

The library waits 100 µs between every edge it makes. One update — four digits, seven bytes, three start–stop pairs — spends about 21 ms doing nothing but waiting.

For a clock, a counter or a thermometer that is invisible. It starts to matter when six displays are being refreshed in a loop, or when 21 ms of blocking upsets something else in the sketch. The fix is the constructor's third argument, which is the delay in microseconds:

TM1637Display display(2, 3, 10);   // ten times faster, still far inside the chip's limit

The chip itself accepts up to 500 kHz, so there is a great deal of room. Long jumper wires are the reason to leave the default alone — the same resistors that hold the wires high also make them slow to rise, and a metre of wire on a breadboard is a great deal of capacitance.

When it does not work

My I²C scanner does not list the display

It never will. The protocol has no addresses at all, so there is nothing for a scan to find, and Wire is not involved anywhere in driving this display. Two ordinary digital pins and the TM1637 library are the whole of it.

Can it share SDA and SCL with my other I²C parts?

No. A real I²C device would see the TM1637's traffic as malformed frames addressed to nobody, and the TM1637 would try to obey bytes meant for the sensor. Give the display two pins of its own — any two digital pins will do.

The chip is rated for 500 kHz, so why is the library so slow?

The library waits 100 µs between every edge, which works out at about 21 ms for one four-digit update. That is deliberate — it makes the code work on long jumper wires and slow boards. The constructor takes a shorter delay as a third argument if you need the speed.

Is the acknowledge worth checking?

writeByte() returns it, but nothing in the library's public functions passes it back to you, so in practice you cannot use it to detect a missing display. Treat a blank display as the error signal instead.

Where this goes next

The clock panel and the digit panel, and the one bit that behaves differently on each.

Two sets, one board

Edit this page — content/books/tm1637-display/two-wires-not-i2c.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

This page covers several products. Choose yours to see the right discussions.

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum