I would like to have a pushbutton play two roles:

  1. Power up my system by connecting battery power to the EN pin on a boost converter, which then powers an MCU

  2. Act as an input for the MCU when the system is powered up.

I was originally thinking of something more complicated than shown below, but I think that an inexpensive dual SPDT analog switch controlled by the MCU might be the easiest option. Hopefully the diagram is self-explanatory. I am wondering if you see any problems with this as shown? Are there precautions that I should take other than the diode shown on the battery line? The diode is to prevent backfeeding the battery when the button is pressed, GPIO1 is driven high, and the lines are not yet swapped. I suppose a current-limiting resistor on GPIO1 would be okay instead (battery voltage is always lower than Vcc)

Dual-role pushbutton

  • \$\begingroup\$ I see now that GPIO1 would also need protection to prevent backfeeding from the battery when the system is off and the button is pressed. Is a single diode adequate for that? \$\endgroup\$ Dec 1, 2022 at 23:26
  • \$\begingroup\$ I also realize now that when the analog switch is powered down, all connections are broken (is that correct)? I misunderstood the NO/NC description. Is there an easy alternative, or other suggestions for how to make this work? \$\endgroup\$ Dec 1, 2022 at 23:40

1 Answer 1


ok, you have 2 GPIO and one enable pin and a single pole switch.

maybe do this:


simulate this circuit – Schematic created using CircuitLab

GPIO 1 can turn the supply on or off and GPIO2 can sense button ptresses.

choose Zener D2 to limit the signal voltage to something apropriate

But that only works if the supply volage is above the logic voltage.

Now that I know the battery is 1 to 1.5V and the logic is 3.3v the follwing might work better.


simulate this circuit

Here the switch turns on the PNP trasnsistor to enable the boost converter

GPIO1 can be used with internal pull-up to sense the buttonn and GPIO2 can be used to command the boost converter. The two diodes should be schottky diodes, the transistor can be any small PNP

  • \$\begingroup\$ Thanks! That’s simpler than I expected. Please forgive my ignorance, but here are a few questions—I assume both GPIO pins would also need protection from the battery voltage when the button is pressed before the MCU is powered up, correct (additional diodes?)? When you say to choose the Zener to bring the signal to an appropriate level, is that if the battery voltage is higher than the MCU voltage? My battery voltage will 1.5 V or less and the MCU is at 3.0 V, so that won’t be an issue… \$\endgroup\$ Dec 2, 2022 at 4:30
  • \$\begingroup\$ … To add one more level of complexity, there could also be a case where the battery is dead and the MCU is powered by USB, in which case GPIO2 couldn’t sense a button press. However, I assume I could also connect GPIO1 to the left side of the button and protect the battery from back feeding with yet another diode (?). \$\endgroup\$ Dec 2, 2022 at 4:30
  • \$\begingroup\$ I was assuming that battery voltage was above CPU voltage, the other way round ruins all my plans. \$\endgroup\$ Dec 2, 2022 at 5:21
  • \$\begingroup\$ looking at my second circuit it should work fine with a second supply on Vdd, the boost converter will have a diode that prevents if from accepting current into the output. \$\endgroup\$ Dec 2, 2022 at 6:04
  • 1
    \$\begingroup\$ That second one looks great to me. My only remaining question is about protection for the GPIO: Would GPIO2 need a diode as well because it will be subjected to voltage from the battery shortly before the supply turns on? Are Schottkys adequate protection for those two pins? \$\endgroup\$ Dec 2, 2022 at 13:43

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.