For an application I am currently developing, I need to be able to get the status of a button (pressed or not pressed) or a switch (which can be considered a button in some way).

While I could theoretically use regular GPIO for this, this will not be a viable solution as the amount of buttons may be up to 50, which would require 2-3 additional Pi's.

Googling around I stumbled upon this bus called 1-Wire. All the examples show tenperature logging, using a DS18B20 if I'm not mistaken, but the concept seemed to fit my use case as well. I figured if something "complex" (compared to a simple button or switch) as a temperature sensor exists for this bus, then surely a simple button or switch must exist too.

Yet I didn't manage to find anything so far, any clues?

  • Sounds like a keyboard. Are you using a Zero? HID emulation might work.
    – bobstro
    Sep 19, 2017 at 0:15
  • 1
    Here is Maxims overview over their different 1-wire chips maximintegrated.com/en/pl_list.cfm/filter/21
    – MatsK
    Sep 19, 2017 at 3:18
  • 1
    Do you need to detect all buttons indenpendently? If not all kombinations of buttons are valid, think about building a key matrix. If you don't need fast reaction (1-wire would not allow that either!), multiplexing would be another option.
    – Philippos
    Sep 19, 2017 at 8:47
  • @Philippos I thought about that but that would still require sqrt(amountbuttons) GPIO pins, which isn't optimal for further extension Sep 19, 2017 at 13:05
  • @MatsK thanks alot, I found something that fitted my case! Sep 19, 2017 at 13:07

3 Answers 3


You can use a I2C GPIO expander to have more GPIO like this one or you can consider pin multiplexing.


Problem solved; I used the link provided by @MatsK (https://www.maximintegrated.com/en/pl_list.cfm/filter/21), it lists several switches that fitted my case.


Maxim make the DS2413 1-wire, only issue I have with the ones I've used is they are rigged as passive power, i.e. only 2 wires to the device (1-wire and Ground) Works great for short cable runs and up to about a dozen devices on the bus, which for me is fine I'm controlling relays to drive a bunch of temp sensors and fridges.

For a big distributed network you'd need to find a version that ran with the 1wire but powered to 5v, I never tried that with the ones I have.

I think 50 would probably overload a single 1wire bus, (I'm at 10 ok) so the i2C expander is probably a better option in the long run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.