Page 1 of 1

Using 4x4 Keypad GPIO 15 and 2

Posted: Wed Dec 30, 2020 11:29 am
by Haehnchen
Hey all,
I am trying to use a 4x4 Matrix Keypad on my NodeMCU esp32 board following this tutorial:
diyi0t.com

I want to use the pins 15, 2, 4, 16, 17, 5, 18, 19 but I get weird results (three buttons hand back the value of other buttons).
When I use the Pins 4, 16, 17, 5, 18, 19, 21, 3 (or other Pins) everything is fine, so I guess there must be a problem with the Pins 15 and 2.
I know that they have special behavior at boot, but I guess that should not be a probleme for the keypad or?
And Pin 2 is conected to the internal LED, might that be a problem?

I tried several boards and keypads so it seems not to be a defect hardware problem.

Is there something special with this pins so that i cant use them for the keypad? Or can it be solved somehow?

Re: Using 4x4 Keypad GPIO 15 and 2

Posted: Wed Dec 30, 2020 2:22 pm
by alanesq

Re: Using 4x4 Keypad GPIO 15 and 2

Posted: Wed Dec 30, 2020 6:57 pm
by Haehnchen
Actually I already read this page several times and I still habe no idea where the problem is.

But i could enclose the problem on the pin 2, Pin 15 is working.

When I use GPIO 2 as Output, it works, but some keys shows the value of other keys, but when I use it as Input, nearly nothing works any more.

On an other esp32 board (without internal led on pin 2) the keypad works on those gpios.

Re: Using 4x4 Keypad GPIO 15 and 2

Posted: Fri Jan 01, 2021 7:10 am
by becorey
The link to the tutorial is broken so it's harder to follow along.

It does sound like you isolated it to just IO2, due to the led. If you tried a different esp32 board, and that one can work with IO2, then the difference is the led and you have your answer. I'm not exactly sure why the led would cause problems. It would draw current from the pin, but the voltage at the IO2 should still either be high 3.3v or low 0v.

What specific 4x4 matrix are you using? Does it use 3.3v?

Looking them up in general, they use 8 GPIO's, one for each of 4 rows and one for each of 4 columns. So it makes sense why an issue would cause one button to return something like the value of 3 other buttons. Your code is just going to check the rows and columns one by one, probably the first one it sees it registers as the button press. If that first one is an error, like holding a high signal, it would interfere in the same row/column.

If you set IO2 as an output, that's just like you're ignoring the button press and directly specifying if it's high or low.