More than one keypad
Two keypads on one bus need two addresses. The TK85 is fixed at 0x20, so a second TK85 needs a second bus; the compact adapter has three pads on its back, and a bridged pad plus a bus scan moves it. Past a handful of adapters, their pull-up resistors add up.
On two boards, nothing to do
Every adapter ships at 0x20, the TK85 and the compact adapter alike. Two keypads on two different boards — two separate I²C buses — both stay at 0x20 and never meet.
Pick your adapter
The TK85 cannot move. Its three address pins are wired to ground under the chip, so it is 0x20 and nothing else. Two TK85s on the same two wires answer every call together, and neither can be read.
So a second TK85 needs a second bus. An ESP32 or ESP32-S3 has two I²C
controllers, Wire and Wire1, each on its own pair of pins, and
I2CKeyPad takes the bus as its second argument:
const int SDA2 = 25, SCL2 = 26; // ESP32; on an ESP32-S3, 4 and 5
Wire1.begin(SDA2, SCL2);
I2CKeyPad left(0x20); // on Wire
I2CKeyPad right(0x20, &Wire1); // the same address, on the other busAn Uno has one bus. There, the second keypad goes on a compact adapter from one of the packs, with a pad bridged.
The compact adapter moves. Its 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); // a TK85, or a compact adapter as shipped
I2CKeyPad right(0x24); // a compact 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 of a compact adapter's pads bridged would give. One set to 0x20 would clash with the TK85.
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 link across the I2C PULLUP pad on every other adapter with a craft knife, and check with a meter that the two halves no longer connect. It is on the back of both forms, and it ships joined.
When it does not work
Both answer at 0x20, so both reply to every call and their answers mix on SDA. The TK85's address cannot be changed. Move one to a second bus — Wire1 on an ESP32 or ESP32-S3 — or swap it for a compact adapter with a pad bridged.
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 PULLUP pad on all adapters but one.
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.