More than one keypad
Two keypads on one board need two addresses: bridge a pad on the back of one adapter, then scan the bus to see where it went. Past a handful of adapters, their pull-up resistors add up, and all but one set has to be cut.
On two boards, nothing to do
Every adapter ships at 0x20. Two keypads on two different boards — two separate I²C buses — both stay at 0x20 and never meet.
On one bus, move one of them
The address is 0x20 plus three bits, one per pad on the back. Each pad is open as shipped, which makes its bit 0. A blob of solder across a pad makes its bit 1.
The labels beside the pads do not match the wiring. The pad printed A0 sets the chip's A2 bit, worth 4, and the pad printed A2 sets A0, worth 1. Only A1, in the middle, is right. So:
- bridge the pad printed A0: the adapter moves to 0x24;
- bridge the pad printed A1: 0x22;
- bridge the pad printed A2: 0x21.
Then scan. The scan is the truth, and it takes ten seconds. The sketch in when a key is wrong prints every address it finds.
Each keypad gets its own object in the sketch:
I2CKeyPad left(0x20);
I2CKeyPad right(0x24); // the adapter with the pad printed A0 bridgedWatch for other boards in the same range. An LCD backpack built on the same chip usually sits at 0x27, which is the address all three pads bridged would give.
Pull-ups add up
Every adapter brings its own 10 kΩ pull-up on SDA and on SCL. Two adapters put two in parallel: 5 kΩ. Eight put 1.25 kΩ. The lower that gets, the harder whichever chip is talking has to pull to get the line down to a 0.
The PCF8574 is guaranteed to sink 3 mA while holding SDA at 0.4 V, and standard-mode I²C is built around the same figure. At 5 V that allows six of these adapters with their pull-ups intact, and at 3.3 V ten — fewer if the bus also has a screen or sensor with pull-ups of its own.
When a bus has too many, keep one set. Cut the trace across the I2C PULL UP pad on every other adapter with a craft knife, and check with a meter that the two halves no longer connect.
When it does not work
That is this board. The design files wire the pad printed A0 to the chip's A2 pin and the pad printed A2 to A0, so the labels are swapped at both ends. The address is still different from 0x20, which is all you needed. Put 0x24 in the sketch.
The solder has not bridged the pad. Look at it with a lens: the blob must touch both halves. Or check with a meter on continuity across the pad. Reheat it with a little more solder if not.
Too many pull-ups in parallel, or an address shared by two boards. Scan with one board at a time to find a clash. If every board answers alone and not together, cut the I2C PULL UP pad on all adapters but one.
Lay solder wick across it and press the iron on top until the wick soaks the solder up. The pad returns to open and the address pin goes back to 0.
Four wires, one library, and a sketch that prints each key as it goes down.
The first keypress →Edit this page — content/books/matrix-keypad/more-than-one-keypad.mdx
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.