Please do not post a support request without first reading and following the advice in

Is sharing I2C pins possible?

  • Hi,
    is it possible to share the I2C interface between a power button and a 16x2 lcd display by assigning different I2C address's? If so how hard is it to implement? Thanks.

    Retropie 4.2
    Momentary power button
    16x2 blue lcd display with I2C module

  • @Boz Please provide more details...a power switch is a passive device, and not an I2C device. What exactly are you trying to get at?

  • I have a power button wired using the following configuration:

    0_1499542906779_led raspberry.png

    and I believe I need pins 5 & 6 to use the lcd screen and scrolling game title script, so I'm wondering if they will both work if wired to the same pins with a bit of jiggery pokery. Thanks.

  • @Boz Why do you need pin 5 ? If pin 5 is already allocated for an I2C protocol then use another GPIO pin. There are other available pins to use. All you are trying to do is detect that the switch was pressed. Why can't another GPIO pin do that besides pin 5?

    Per your diagram above, pin 5 is the clock signal (SCL1) for I2C. If the switch is pressed, you will be shorting pin 5 (SCL1) to Ground, which will cause the I2C to fail and if you do this for several times or hold it for more than a second, your Pi will eventually cease to function or possibly the LCD as well.

  • I'll give you the full story (bear with me): I had a hifiberry dac + connected (which uses GPIO2/3 and 18-21 to work) so I swapped GPIO3(pin5) for GPIO4(pin7) and altered the script I was using accordingly.
    This resulted in me being able to turn off the pi using the button, but not turn it back on again.
    I contacted the Hifiberry team about it who told me that using GPIO 3 to turn the pi on was a bit of a hack and wouldn't work with other pins. To get round this i bought a Hifiberry dac+ light which doesn't need GPIO 3 (pin 5).
    So as it stands i have the button working and the dac working and i was trying to get the lcd working also. I'm a bit of a noob as far as GPIO related things are concerned and I've only really been following the advice I've been given so far.
    I haven't tried any other pins other than GPIO 3(pin5) which works for me and GPIO 4 (pin7) which doesn't work for me. Is there another pin that will work?
    It's worth noting that i connect to GPIO pins via the pins(holes) on the dac board.


  • So you are talking about I2S!
    What LCD do you have? usually the I2C is the touch device unit.

  • @cyperghost I'm using the QAPASS 16x2 white on blue LCD with i2c module attached. I think it's the same one used in this thread:

  • I2C is multimaster /multislave bus and may handle I2C and I2S together. But really you've to test out!
    But im asking way you take this task and use I2S for a LCD (which seems HD compatible) and do not use direct wiring or UART.

  • @cyperghost Like i say I'm a noob and need advice on whats best. I'm not doing it this way for any reason other than I've followed a tutorial on connecting the power button and I've followed advice from hifiberry.
    What do you think would be best?

  • This is the lcd here:

    it's just for scrolling game title text and other system info.
    I planned on following the wiring/script in this thread:

  • I would use annother LCD. SPI is much better but needs really good knowledge.
    From your state I would do the following. These LCDs are really easy to use and connect. Buy one without a controller (these devices costs ... well 1-3$), buy a breadboard and just play with it a bit.

    As I said, these displays are usually connected to I2S, UART (both seriell) or parallel. HD44780 is the magic word. This is the controller of the display itself and can directly be connected to digital output (=GPIO). But you can solder annother controller on top and the I2C or UART controllers then internally "talk" to the HD44780 and the user connects to the interfaces provided!

    There are some with 4x20 characters available und I would work in 4bit mode. So you need 4 simple GPIOs , 5V and ground and 2 lines for set controller to send and receive mode. This will work 100% without the need of juggling around with I2C. But that's my attitude - I think good sound is better than just the need of a display.

  • Thanks for the reply,
    this was only really for finishing touches to a enclosure I'm building and not a necessity. The sound is brilliant, and i agree sound over scrolling text any day. I will look into HD44780 and see what info i can find thanks. From what I've read the adding of a i2c module to the display is to simplify wiring but looks like it will only complicate my setup.

  • Turns out my display is a HD44780 with a i2c backpack soldered to it. I also have one of these displays without the i2c module aswell. I found some info relating to wiring using UART:

    But to be honest this will massively over complicate things and feel a little out of my depth!

  • @Boz For UART you will need annother controller.
    Just play around with your LCD. Try to get it work with I2C and then try to get it work an GPIO. Don't give up ;)

  • I re-read the site where I got the power button info:
    In the comment section of this page someone calls this method "interesting" as if it probably wasn't a good idea.. he asked if it would cause damage to an already connected device that uses the i2c bus.
    Barry Hubbard never replied.

  • Ok so I didn't give up so to speak but I did take a different route, I now have a ATXraspi sorting out my power button which leaves my i2c pins freed up. I have connected my 16x2 display as per the guide I've been following but when I check the i2c address there is no assigned address can anyone help me? Thanks. (there is power to the display but no text)

Log in to reply

Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.