# Power on for a few minutes, with physical button

**URL:** <https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024>\
**Category:** General Guidance\
**Created:** [June 25, 2013, 5:56pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024 "2013-06-25T17:56:40Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 25, 2013, 5:56pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/1 "2013-06-25T17:56:40Z")

</div>

I want to have a device that has a physical button that will turn it on, and after a few minutes, shut itself down. By using millis() I can keep track of how long it's running.

The parts I am unsure about is how to have a button (preferably a capacitive or momentary push) to turn in on and then how to turn off the power to my circuit. It will be powered by a battery, and will monitor the voltage coming from with a voltage divider, so I assume (not sure if correct) that this would continue to draw power, even if the Arduino is not running.

I would appreciate any suggestions on how to accomplish this.

---

<div class="post-metadata">

**Author:** ![pito](https://avatars.discourse-cdn.com/v4/letter/p/e68b1a/32.png) [@pito](https://forum.arduino.cc/u/pito)\
**Post date:** [June 25, 2013, 6:03pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/2 "2013-06-25T18:03:09Z")

</div>

You can do it such it will draw no current. Long time back I did it with a push-button and a relay - the pressing the button powered an mcu, mcu switched the relay on, the relay's contact shorted the button. Thus it started to operate, when the time came, the mcu switched the relay off, the whole system powered itself fully off.  
Today you can do it with a mosfet.  
PS: Pin out - a NPN transistor switch there when working with voltages higher than 5V.

![butrel.jpg](https://europe1.discourse-cdn.com/arduino/original/4X/0/0/b/00bc0c5c87c7537c29d4d90a7a4428dff6c12b2d.jpeg)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 25, 2013, 8:48pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/3 "2013-06-25T20:48:12Z")

</div>

> pito:  
> You can do it such it will draw no current. Long time back I did it with a push-button and a relay - the pressing the button powered an mcu, mcu switched the relay on, the relay's contact shorted the button. Thus it started to operate, when the time came, the mcu switched the relay off, the whole system powered itself fully off.  
> Today you can do it with a mosfet.  
> PS: Pin out - a NPN transistor switch there when working with voltages higher than 5V.

Thanks - the battery voltage provided will be under 8v.

For this project, using SMT would be preferred. I've not very familiar with using a mosfet (still new to the H/W side of this world). Can you point me in a direction to learn how to use transistor for this purpose?

Thanks again.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 25, 2013, 9:13pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/4 "2013-06-25T21:13:31Z")

</div>

> mhectorgato:  
> For this project, using SMT would be preferred. I've not very familiar with using a mosfet (still new to the H/W side of this world). Can you point me in a direction to learn how to use transistor for this purpose?
> 
> Thanks again.

This should help —

[https://www.google.com/search?q=how+to+use+mosfet](https://www.google.com/search?q=how+to+use+mosfet)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 25, 2013, 9:18pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/5 "2013-06-25T21:18:58Z")

</div>

> 1ChicagoDave:
> 
> > mhectorgato:  
> > For this project, using SMT would be preferred. I've not very familiar with using a mosfet (still new to the H/W side of this world). Can you point me in a direction to learn how to use transistor for this purpose?
> > 
> > Thanks again.
> 
> This should help —
> 
> [how to use mosfet - Google Search](https://www.google.com/search?q=how+to+use+mosfet)

A lot of the searches I did for mosfets were related to using an Arduino to drive powerful motors or lights. Not many seemed to be related to using it as a simple power switch.

I'm a software developer coming to the hardware world. So it might be staring me right in the face and I'm not seeing.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 25, 2013, 9:36pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/6 "2013-06-25T21:36:14Z")

</div>

I hear ya. I wasn't being a smart-ass. I did that google search myself and many of the results included the phrase "using a mosfet as a simple switch". I'll take another look & see if I can rephrase/explain it with your application in mind.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 25, 2013, 10:02pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/7 "2013-06-25T22:02:23Z")

</div>

It's essentially the same as using them to drive motors or lights. Only, instead of having a motor or light attached to the FET, attach the low-current/low-voltage side of a relay to the FET. Use a Power FET so it will most likely either be in the 'ON' or 'OFF' modes...depending on if Arduino is sending current to it (ON) or not (OFF).

An N-Channel transistor is essentially a gate (like a water faucet?). When it receives a current it turns on and lets power flow through the other two contacts. When it stops receiving current (to its 'gate' pin) it restricts flow from "Drain" to "Source" pins.

You'll have to check some DATASHEETS to determine which FET to use for the currents & voltages you are using. But,other than that, I'd suggest getting your breadboard setup with a FET, relay, etc, and play around to figure it out.

If you need help better understanding how transistors work, I'd suggest starting at either "[talkingelectronics.com](http://talkingelectronics.com)" and/or YouTube(a guy named "AfroMan" has some great tutorial videos on transistors). That's where I learned a lot when I started out.

Good luck! And, if you can be more specific about any further questions, it would help us to help you. Like....what specs the transistor needs to work with arduino? Which pins to attach where?

Here's one page that should really help you with this.

> **[MOSFET as a Switch - Using Power MOSFET Switching](https://www.electronics-tutorials.ws/transistor/tran_7.html)**
>
> Electronics Tutorial about the power MOSFET as a Switch and using the MOSFET as a Switch to control relays, motors and other high current electrical loads

It has a great explanation, good schematics, and even a section titled "An Example of Using MOSFET as a Switch". Just hook up your relay where the "lamp" is in that example.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 26, 2013, 1:11pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/8 "2013-06-26T13:11:16Z")

</div>

> 1ChicagoDave:  
> It's essentially the same as using them to drive motors or lights. Only, instead of having a motor or light attached to the FET, attach the low-current/low-voltage side of a relay to the FET. Use a Power FET so it will most likely either be in the 'ON' or 'OFF' modes...depending on if Arduino is sending current to it (ON) or not (OFF)....

Thanks for the help -- very much appreciated!!!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 26, 2013, 4:43pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/9 "2013-06-26T16:43:04Z")

</div>

So now that I've learned a little about MOSFETs, does the attached schematic make sense?

When Arduino is powered down, will the voltage divider still draw current from the battery?  
If so, if I wanted to remove that parasitic drain, could I use MOSFET there as well?

 ![transistors.PNG](https://europe1.discourse-cdn.com/arduino/original/4X/e/a/2/ea26a730ee3e6c476fdee808ae5b47d1a7bc25cc.png)

---

<div class="post-metadata">

**Author:** ![KevinArduino](https://avatars.discourse-cdn.com/v4/letter/k/58956e/32.png) [@KevinArduino](https://forum.arduino.cc/u/KevinArduino)\
**Post date:** [June 26, 2013, 4:58pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/10 "2013-06-26T16:58:51Z")

</div>

> You can do it such it will draw no current. Long time back I did it with a push-button and a relay - the pressing the button powered an mcu, mcu switched the relay on, the relay's contact shorted the button. Thus it started to operate, when the time came, the mcu switched the relay off, the whole system powered itself fully off.  
> Today you can do it with a mosfet.

Thank you for this I think you just solved my problems as well, I was taking the entirely wrong approach. Anyway could you explain the function of the diode in your circuit and is that still necessary using a MOSFET?

---

<div class="post-metadata">

**Author:** ![3dprinter](https://avatars.discourse-cdn.com/v4/letter/3/7993a0/32.png) [@3dprinter](https://forum.arduino.cc/u/3dprinter)\
**Post date:** [June 26, 2013, 10:27pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/11 "2013-06-26T22:27:05Z")

</div>

The diode is there to absorb the back EMF of the relay. When the current to the relay is switched off, the magnetic field turns off. Seen from the coils point of view, there was a magnetic field that then disappeared - which is the same as pulling a magnet out of the coil - which generates a current/voltage. That is the Back EMF. It can be a high enough volatge to destroy the FET or, in particular when connected directly to Arduino ports, the chip. The diode wil lnot do anything when the current goes the right way through the relay, but when switched off the backEMF (which is the opposite polarity) will flow through the diode.

(edit corrected 10 typos)

---

<div class="post-metadata">

**Author:** ![Coding\_Badly](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@Coding\_Badly](https://forum.arduino.cc/u/Coding_Badly)\
**Post date:** [June 26, 2013, 11:15pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/12 "2013-06-26T23:15:13Z")

</div>

> **[Pololu Pushbutton Power Switch LV (old version)](https://www.pololu.com/product/751)**
>
> The Pololu Pushbutton Power Switch is a patented design initially created for our Orangutan Robot Controllers as an alternative to bulky mechanical switches. The switch is intended to be the main power switch for a DC device requiring up to several...

$6. Works a treat.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 27, 2013, 12:51am UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/13 "2013-06-27T00:51:54Z")

</div>

> [@](#):
>
> [Pololu Pushbutton Power Switch LV (old version)](http://www.pololu.com/catalog/product/751)  
> $6. Works a treat.

Nice! Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 4:55pm UTC](https://forum.arduino.cc/t/power-on-for-a-few-minutes-with-physical-button/170024/14 "2021-05-05T16:55:28Z")

</div>

Closed on May 5, 2021, 4:55pm UTC


