Interfacing TM1638 devices with Arduino for ESP32

MartyMacGyver
Posts: 56
Joined: Sun Dec 18, 2016 9:17 pm

Interfacing TM1638 devices with Arduino for ESP32

Postby MartyMacGyver » Tue Feb 07, 2017 11:35 pm

I recently got a board that uses the TM1638 keypad and LED array driver. While it seemed like it'd be simple to interface, it was having odd problems with the ESP32 configuration (particularly, only the first few buttons worked reliably, while the rest produced sporadic data).

Turns out a fair number of people using the TM1638 have stumbled on such issues when using higher-speed devices with Arduino libraries. It's been ascribed to voltages (though the board actually works fine with 3.3V or 5V as long as the I/O is properly level-shifted), "bad boards" and so on (though the actual switches can be wonky, they are actually a secondary issue). Running at 5V with signal level shifting didn't help at all. However, I tested this with other Arduino-type boards like the Particle Photon (at 3.3V) and it worked just fine. What was going on?

The problem is that the native Arduino shiftIn()/shiftOut() wire functions are simply too fast for this device (technically the clock signalling for the TM1638 is inverted but as it triggers on a rising edge still it is evidently tolerant of that).

So, if you're trying to interface a TM1638-based device to an ESP32 (or other fast MCUs like the ESP8266) via Arduino the demos I created (with customized implementations of shiftIn() and shift Out() that give delay and clock edge options) may be of use:

https://github.com/MartyMacGyver/TM1638 ... d-examples

Who is online

Users browsing this forum: No registered users and 14 guests