2 Button Shims? SUCCESS


#1

I really want 10 buttons for decimal input on a Pi Zero, and if 2 button shims could coexist, that would fit the bill nicely.

If someone were to carefully cut pin 1 on the chip and then ground it, would that change the i2c address from 3f to 3e and allow two button shims on a single Pi?


#2

Do you have a link to the pinout of that chip? I did a Google search but didn’t find the SMT version, I only found the dual inline pinout.


#3

I believe it to be this one as per this thread.

The default i2c address of 3f is set by pulling pins 1, 2 and 3 high. Please correct me if I’m wrong.

I think I could cut pin 1 since it is on the end, bend it up or to the side, and solder a jumper wire to ground. Maybe. Those pins are very tiny.


#4

That was the same link I found when searching. It shows an inline chip, not the SMT chip used on the button shim. If the pinout is the same what you want to do is doable. It also shows those 3 address pins all connected to ground in the simplified block diagram. Also, I do believe, when they are pulled high its done vis a pull up resistor. @gadgetoid Phil would know better than I how Pimoroni wired them up. It might be as easy as grounding one end of a resistor to change the address. Pull the pin(s) low instead of high.


#5

Ok, so, I double checked that pins 1-3 of the onboard chip read high (i.e. they match the document) and then took the plunge and gently desoldered pin 1.

i2cdetect now reads it as at address 3e. Putting two Button Shims on 1 Pi shows one at 3e and one at 3f.

Of course the libraries will have to be sorted out, but this should definitely work!


#6

Nicely done. I know how to do it with sensors in python, not sure how you do it with the button shim though?
For a BME680 its something like this.
sensor1 = bme680.BME680(76)
sensor2 = bme680.BME680(77)
I didn’t see anything like that in the examples. That may be because its using evdev to detect button presses?
There is a way to detect the codes for the buttons and make note of them. I’ve done it in the past with USB devices like USB connected IR remotes and cordless keyboards. I’ll see if I can find that info.


#7

Not sure if this helps or not, but this is how I got the button codes for my keyboards etc.
https://learn.pimoroni.com/tutorial/robots/controlling-your-robot-wireless-keyboard

I did some tinkering with evdev a long while back. I don’t think I have any of the links saved anymore though. I used it with my Sense Hat joystick / hat switch thingy. The Pi Foundation eventually added proper support for it in python so I ditched using evdev.


#8

Because the button shim comms all go through i2c, I’m just using the supplied python library. And since the “keyboard.py” example does what I need, I’m basically using that with a simple change to input keys 1-5. Yes, it uses evdev.

I was really lazy about getting the library working with the modified shim. The I2C address is hard-coded into the button-shim library and I’m still a beginner with Python. I simply duplicated the library with the I2C address for the 2nd button shim and created a 2nd keyboard.py based script that uses the dup library to input keys 6-0.

I’m really surprised at how easy this was, and being able to input all 10 digits in a really slim form is really nice. Pimoroni really should consider supporting this officially with a solder-jumper on the button shim.


#9

Some pHats hats etc have a changeable address, some don’t. The size of the board, free space etc, likely factors into it. And how complex the layout is. I would say a lot of these boards are only double sided, not multi layer, to keep the cost down. That only leaves so much space to run your tracks on the board. And the intended use and how they hook up to the Pi likely factors into it too.
I did some printed circuit design many moons ago. It can be very challenging getting the layout correct, and or the way you want it. All through hole stuff, like I said, many moons ago lol.