Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.

Two Push-button Power Switch Breakouts
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Two Push-button Power Switch Breakouts

by ian224 on Tue Aug 11, 2020 12:45 pm


I'm attempting to build a battery powered Arduino project which is economical with power consumption in order to maximise battery life. I have been experimenting with the Push-button Power Switch Breakout and have got a semi-working prototype but would appreciate some electrical engineering input if anyone can help...

My goal is to build a device with two user input switches with the following features:
    When either of the switches are pressed, the device turns on, does some stuff and then turns itself off again to preserve battery
    I would like to know which of the two switches was pressed in order to turn the device on as this influences the actions to be completed
    Ideally I would like to also know if both buttons were pressed during the same period of activation
    I would not like the user to be able to cancel any button presses by toggling the device on and then off again
    I am using an Arduino MKR board with s 3.7V LiPo battery as power source

It seems that the Push-button Power Switch Breakout is ideal for this task, and if I only wanted a single input button then this is a walk in the park. However, with two switches in play things become more complicated and as a mechanical guy, rather than an electronics guy, I am struggling. I have breadboarded a prototype which gets most of the way to doing what I want (see image). Here is what I have done:

    I have two Push-button Power Switch Breakouts chained together in a sort of 'primary-secondary' relationship. I have connected together the In, G and Off pins of the two breakouts
    In and G are connected to the LiPo battery
    I have connected one side of the tact switches to ground so that pressing the switches turns the power switch breakouts on but not off, this means that the breakouts can only be switched off via the off pin by the Arduino
    Breakout 1 operates as the primary input; its Out pin is connected to the Arduino so when breakout 1 is active then the Arduino does its stuff
    Breakout 2 operates as the secondary input; its Out pin is only connected to a digital input pin 8 of the Arduino, so turning on breakout 2 on its own does not do anything. However, switch 2 is also connected to breakout 1 via a diode, so pressing switch 2 activates both breakouts. The diode means that pressing switch 1 does not activate breakout 2
    When the Arduino turns on, it is able to query pin 8; if it is low, then breakout 2 is off and button 1 must've been pressed. If it is high then breakout 2 is on and button 2 must've been pressed
    The Off pin is connected to pin 7 of Arduino and is set high when all actions are completed to turn everything off

This current setup works from a power consumption standpoint, allows me to differentiate between the two different button presses, and prevents the user from cancelling. However I am currently unable to detect if both buttons were pressed because of the primary-secondary relationship. Also, if button 1 is pressed immediately followed by button 2, then this is processed as a button 2 press, whereas if button 2 is pressed immediately followed by button 1, this is also processed as a button 2 press, which has potential for user confusion.

Things I have also tried/thought:

    Directly connecting the Out pins together causes both breakouts to turn on whenever either button is pressed
    Adding diodes to the above arrangement fixes the activation problem but causes too much voltage drop for the Arduino to be correctly powered
    I could add a third breakout (with no physical switch) to act as the primary breakout and have both switches acting as secondary, but this seems like overkill and I figure there must be a more elegant solution?
    Maybe I could use a transistor/MOSFET to act as a digital switch between the two outputs, but I have no idea whether this would also suffer from voltage drop issues

Any advice on how I might be able to modify my circuit to allow detection of both buttons being pressed (preferably without having to add another breakout) would be greatly appreciated.


IMG_3286.JPG (521.54 KiB) Viewed 16 times

Posts: 1
Joined: Tue Aug 11, 2020 10:57 am

Please be positive and constructive with your questions and comments.