2
\$\begingroup\$

I'm using the Raspberry Pi's GPIO to display some information in a LCD (using I2C) and to enable the usage of a few buttons to navigate through the LCD menus. There's another button, the one I'm having some trouble, that will work as a power-on button.

The problem is: You can power up a Raspberry Pi (3 B+, at least), by shorting pin 03 with ground (which is what I'm doing with the power-on button and works wonderfully), *BUT, this is also the SCLK pin that is needed by the I2C shield to work. I can just let both of them connected, but if someone presses the power on button while the Pi is on, it will reset the LCD and maybe crash the service that sends data to the LCD.

How I tried to solve: Pin 13 (TXD) goes high when a Raspberry is on and that it goes low when the Pi is halted. So I used a PNP transistor where Pin 13 is connected to it's base and when this pin is high (3.3v), it will be able to "turn on" the transistor. This transistor is the one that will be connected to the base of our NPN transistor, while this NPN transistor connector pin will be connected to GND and it's emitter to our switch, which is connected to Pin 03. By doing this, I expect the negative potential between GND and NPN transistor's VBE to be able to make this NPN transistor to be turned off. And when the pin is low (1.5v), it won't be able to "turn on" the PNP transistor which will keep our NPN transistor on it's normally open state and will let the power on button work. There's also a transistor which was used solely to decrease pin 13's voltage.

So.. here's the schematic (the board that I'm creating will be an intermediary one between the Pi and my I2C shield, that's why I'm using a connector instead of other parts):

schematic

Does it all makes sense? Is this a good way to solve this problem? I've simulated it on Multisim online simulator and it seems to work, but it seems a little bit strange for me.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

Pin 13 (TXD) goes high when a Raspberry is on and that it goes low when the Pi is halted. You can power up a Raspberry Pi (3 B+, at least), by shorting pin 03 with ground.

The left one drives pin3 to 0.2V, while the right one drives to 0.6 + Pin13.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
3
  • \$\begingroup\$ It took me a while to figure out how the left one works, but are both Q3 and Q4 NPN transistors? Or should Q4 be the PNP one? Asking this because if Pin13 is high, SW2 should not work (or it would mess with the LCD), so if Q4 is an PNP, it will be "enabled" when Pin13 is low (~1.5v) and "disabled" when Pin13 is high (~3.3v). Did i got it right? \$\endgroup\$
    – dan_soah
    Sep 29, 2021 at 14:26
  • 1
    \$\begingroup\$ @dan_soah When pin13 is high, Q4 turns on and pulls r2 & Q3 base to ground. Thus, Q3 is disabled. While pin13 is low, Q4 is turned off, Q3 is biased through R2, and Q3 turns on. \$\endgroup\$
    – jay
    Sep 29, 2021 at 15:35
  • \$\begingroup\$ Got it, makes a lot of sense. Thanks for the clarification :) \$\endgroup\$
    – dan_soah
    Sep 29, 2021 at 17:00
0
\$\begingroup\$

Another option is to change the pin03 standby function to another pin. You cannot change the "on" function but you can change the "standby" function to a different pin so you'll need both an on and off button.

This is a common solution for your exact problem with I2C.

To change the shutdown pin from GPIO 3 (default) to GPIO 26 (physical pin 37), add this to /boot/config.txt

dtoverlay=gpio-shutdown,gpio_pin=26

From one of many examples on Pi forum... https://www.raspberrypi.org/forums/viewtopic.php?t=217442

\$\endgroup\$
1
  • \$\begingroup\$ I've thought about this too, but my "shutdown" function is triggered by using the other three buttons and navigating through the LCD. There's an "shutdown" item which will trigger a "shutdown -h 0" through the base service which feeds the LCD. The only missing part was this issue with the startup button, but thanks for the idea :) \$\endgroup\$
    – dan_soah
    Sep 29, 2021 at 13:27

Your Answer

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

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