The usual way to wire up a SPST switch to a MCU is by means of a pull-up resistor. However, this wastes current when the switch is closed. If this switch is used to wake up the MCU from sleep, then this current (100-500 µA) is significant compared to the sleep current (< 0.1 µA). I imagine increasing the resistor value up to megaohms wouldn't be practical for a number of reasons. So is there a better way to interface a SPST in general? I have a couple of pins on the MCU to spare (but keep in mind the MCU has to be put in sleep most of the time - it should wake up and do its stuff only when the switch state changes).

The only solution that comes to my mind is to basically use the pull-up scheme, but buffer it through a P-MOSFET/N-MOSFET pair for increased input impedance.

And yes, I realize the solution is trivial if we were dealing with a SPDT or a push-button.


2 Answers 2


If the latency (in reading the switch) was acceptable at once per 100 milliseconds then why not let the micro wake up for a short period (in as low a current mode as possible), energize the switch's pull-up briefly, read the switch, then do what it has to do then re-enter sleep mode.

The switch is only briefly taking current when the micro wakes up.

Maybe the problem with this scenario is that the micro wakes up for 1 millisecond and consumes 1mA for that period BUT if it only does this once every 100 milliseconds then its average consumption is 10 uA. At least that may be better than energizing a closed switch continually?

As an aside you've got to take care to feed a switch with enough current to break thru oxide layers that form - it's called the switch's wetting current and some can be several milliamps.

  • \$\begingroup\$ Oh, you're right of course. This is totally workable. For some reason I've gotten under the impression that PICs' WDTs always cause a reset, but reading the specs more thoroughly I see now that in sleep they just wake the device up, which is perfect. I'll use this path, thanks! \$\endgroup\$
    – anrieff
    May 7, 2014 at 20:51

There's a catch here- usually the switch wants to see a minimum current to be reliable, perhaps 100uA is specified as the minimum current for a gold-on-gold switch.

You may be able to switch the current by using a couple of port pins to reduce the current so it it switches (say) 0.2mA and then once the switch has settled down, you reduce the current and wait for a break in the current.


simulate this circuit – Schematic created using CircuitLab

So when you detect a "high" you energize the high-current pullup R1, and wait for a LOW. When you see a LOW you wait for maybe 20msec then de-energize the high-current pullup and energize the "high" side.

This is operating well outside the guaranteed range of most micros (two outputs must leak much less than 1uA) and also the switch (it only sees the minimum current when switching), so caveat emptor.

  • \$\begingroup\$ This is SPDT - my question was about the plain old SPST. Simple SPDTs can be read by placing 5v/GND as the alternatives on the one side, and a MCU pin on the other. Set the pin as interrupt-on-change and bam, you've got a 0.1 µA solution. \$\endgroup\$
    – anrieff
    May 7, 2014 at 20:49
  • \$\begingroup\$ I think the OP made it pretty clear that using a SPDT wasn't an option...did you see the last sentence in the question? \$\endgroup\$
    – Joe Hass
    May 7, 2014 at 20:49
  • \$\begingroup\$ Okay, eliminated the second half of the switch, the point is that you can get fast response with this method while maintaining low current (and it might work). \$\endgroup\$ May 7, 2014 at 20:55

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.