Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TM1637 - Buttons don't work on esp32 #56

Open
ANLCRAW opened this issue Oct 8, 2024 · 4 comments
Open

TM1637 - Buttons don't work on esp32 #56

ANLCRAW opened this issue Oct 8, 2024 · 4 comments
Assignees
Labels
good first issue Good for newcomers question Further information is requested

Comments

@ANLCRAW
Copy link

ANLCRAW commented Oct 8, 2024

Thanks for your library! I’ve been using it with the ATmega328P and costom pcb, but now I'm switching to the ESP32 and after 24 hours of struggling, I discovered that I need to change 'delayMicroseconds(5)' to 'delayMicroseconds(330)' in tm1637.cpp to make the buttons work. Else i get de default display printing of 0x8000 / no buttons / 1111-1111. I'm using de tm16xxButtons_clicks example. Anyone else have experience with this? I'm using a MH-ET LIVE

@maxint-rd maxint-rd self-assigned this Oct 8, 2024
@maxint-rd
Copy link
Owner

maxint-rd commented Oct 8, 2024

Hello @ANLCRAW - thanks for taking the effort to find the root cause of your issue and for posting this.
You're the first I know to encounter this specific case. I have tested the library on ESP32 (on my TinyPico board), but probably not all with combinations of displays. In some cases I did need to change introduce delays to facilitate faster processors. I think I need to setup a test environment to test this myself and see if I can reproduce your findings.

The MH-ET LIVE board looks a lot like the D1 mini. I do have the ESP8266 variant of that board, but I don't think I have it with an ESP32. However, I think my TinyPico should suffice for testing this.

Can you tell me what version of the Arduino IDE and which version of the ESP32 core you are using? At what clock speed is your ESP32 running? In some tests I ran my ESP8266 at 80MHz and the RP2040 at 133MHz. I can't remember what speed I ran the ESP32 when testing. I'm not sure if 240MHz is the default speed/.

I don't know when I can find some time to test this, but I will keep this issue open and post my findings here.

Edit: on TM1637 reading keys should be slower than 250Khz (see datasheet p3). For that reason the delay between reading bits should be more than 4us and 5us was chosen. When testing the library on faster processors I did find that good connections and a good power supply were crucial.
During some tests I struggled to get things working only to find out that the breadboard connections were not reliable. When using I2C slowing the speed helped, but it was better to use short jumper wires on a good breadboard. In other test issues seemed power related and adding a capacitor to the power pins was sufficient to have good results.

@maxint-rd maxint-rd added good first issue Good for newcomers question Further information is requested labels Oct 8, 2024
@ANLCRAW
Copy link
Author

ANLCRAW commented Oct 8, 2024

Super thanks for your quick reply. The "MH-ET Live Minikit" resembles a D1 Mini, but I have the "MH-ET Live devKit," which is more like a NodeMCU, though that probably doesn't make much difference. The ESP is an "esp-wroom-32," and to my knowledge, it's running at 240MHz 80MHz. I am using the "espressif esp32" core version 3.0.5 (MH-ET LIVE ESP32DevKIT) with the latest Arduino IDE version 2.3.3. ESP32. runs at 80MHz.

As I’m typing this, I am removing the espressif esp32 core (https://github.com/espressif/arduino-esp32) and trying the core provided by MHEtLive (https://github.com/MHEtLive/arduino-esp32), hoping that it might make a big difference. I will let you know my findings.

The wires between the ESP and the display are no longer than 2 centimeters. The TM1637, buttons, and display are all on a PCB.

I hope to find a solution because going from 5ms to 330ms is very noticeable when navigating through the menu. I’ll keep searching. It’s likely not your fantastic library causing the issue but something on my end. I’ve already ordered new TM1637 chips to rule out the possibility that the chips are the problem.

@maxint-rd
Copy link
Owner

Thank you for the swift response to my questions. The delay is used at multiple points, so an increase from 5us to 330us will add up. (I assumed you meant to write 330us instead of 330ms (milliseconds) as 330ms would definitely be unworkable). You mention both 240MHz and 80MHz. Was the issue the same when running at the slowest speed?

One thing I didn't ask yet is about the color of the leds and the supplied voltage. Most TM16xx chips work fine on 3v3, but I did notice some issues when using blue led display instead of red. The blue leds require higher voltage and may require a level shifter.

When I can find the time I'll try to match your setup. Some years ago I made a small TM1637 matrix PCB that allows the addition of three buttons. I used it to make this clock, Before making those PCB's I modified a TM1637 4x8 segment display module into a mini LED&KEY module. I still have plenty TM1637 chips to do some experiments.

Your chip may be defective or perhaps just less reliable at higher speeds. On one occasion I had a TM1640 matrix module on the RP2040 which gave random glitches, but only on the RP2040, not on slower processors. I tried everything including analysis with a scope, but couldn't find the issue. Sometime later I tried again, but then also tried another matrix module. Guess what: one module displayed the glitches while the other module worked just fine. In that test it seemed to be a combination of a chip less reliable at higher speed plus iffy breadboard connections.

@ANLCRAW
Copy link
Author

ANLCRAW commented Oct 8, 2024

Apologies for my little mistakes; they have been corrected. I did indeed mean microseconds (µs) and not milliseconds (ms). Although I wasn’t very clear about it, what I meant is that the ESP32 is a 240MHz chip, but I’m running it at 80MHz. Lowering it to 40MHz makes no difference. Using the MH-ET core also made no difference, so I’m back to using the Espressif core 3.0.5.

This is what my current PCB looks like:
Schermafbeelding 2024-10-08 220634

Good videos by the way... lekker op zijn hollands!

I am almost one hundred percent sure that the issue lies with the TM1637 chips. The first two TM1637 chips I used came from a 7-segment DIY module, and I then bought a batch from AliExpress. The chips from the 7-segment module apparently don’t work on the ESP32, and the new batch doesn’t work on the Atmel328p. Viceversa.

While waiting for the new chips to arrive, for anyone who has had the same experience... not every chip is the same, something I was aware of but had never experienced so clearly. There are plenty of rejected chips being sold.

Thanks again for your response, and I’ll share my findings here in a few weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants