Power on for a few minutes, with physical button

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.

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

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.

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

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

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.

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.

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" 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.

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.

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!!!

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?

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?

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)

$6. Works a treat.

Nice! Thanks.