matrix keypad/Limits and more keypads/08. More than one keypad
Limits and more keypads · 08 of 11

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.

Three pads, eight addresses
0x24
Bridge a pad with solder (by its printed label)
Answers at
0x24
The labels suggest
0x21
Addresses possible
8
0x24, not 0x21. On this board the pads printed A0 and A2 reach the chip’s A2 and A0. Nothing is damaged and the keypad works — it is just at a different address from the one the label promises. Scan the bus after soldering and use whatever it prints.

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 bridged

Watch 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.

Pull-ups add up
2 × 10 kΩ at 5 V
Adapters on the bus with the pull-up pad intact2
Bus voltage
Combined pull-up
5.00 kΩ
To pull SDA low
0.9 mA
Most at 5 V
6 boards
Fine: 0.9 mA is inside the 3 mA an I²C chip is built to sink. At 5 V the bus stays within limits up to 6 of these adapters, fewer if your other I²C boards bring pull-ups of their own. Past that, cut pads until one set is left.

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

I bridged A0 and the scan shows 0x24, not 0x21

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.

Both adapters still answer at the same address

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.

The bus stopped working when I added more boards

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.

How do I undo a bridged pad?

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.

Where this goes next

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

Community

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.

Browse Modules and blocks on the forum