Turn on Arduino on pressed button

Hi to everyone.

I'm a french student in engineering school (so sorry about my English mistakes), and I'm contacting you today about one of my personals projects.

It is the first time I post something on a forum because I really need help, I'm blocked.
I try for an intelligent remote project to turn On an Arduino Nano board on a pressed button and turn it Off after a scheduled inactivity timer.

To achieve this, I tried the schematics (figure 1) with a button directly linked to the 5v battery that is plugged to the VIn port of the Arduino. For the moment the Arduino power the D5 port with 5v. A transistor base is linked the D5 port to commutate and then enable a power loop. The transistor's collector and emitter are derivates to the button to get the 5v from the battery. I hope it's more or less clear with the Schematic.

However, when I press the button down, the Arduino turn On, the D5 port is high that enable transistor loop and power the board by itself but as soon as I release the button everything shut down. I tried to had a 35v 100uf capacitor to the D5 output to keep some power on release and then continue the loop, but this doesn't work ()Maybe 5v is to low ?).

I stay at your disposal for any unclear information or a complementary one.
Thank you very much for your help,

Gus.

What code is running on the Arduino ?

For the moment to test the function, the only code running is :

void setup() {
pinMode(5,OUTPUT) ;
digitalWrite(5,HIGH); // turn D5 5v output
}

void loop() {
// put your main code here, to run repeatedly:

}

Is the button normally closed, as in your schematic, or normally open ?

No the button is normally open sorry about that.
When I press it, the arduino is powered.

Your circuit cannot work. You are supplying the base of the transistor from the Arduino, the Arduino gets it's supply from the emitter of the same transistor, so in effect you are just connecting the base to the emitter. The base needs to be fed via a current limiting resistor from a voltage higher than you want the emitter to be. Circuits like this need 2 transistors, either 1 NPN and 1 PNP, or preferably, 1 N channel MOSFET and 1 P channel MOSFET.

Thank you Perry, that was what I supposed.
Can you give a quick schematic or a link with documentation to see the new circuit ?
Thank you very much for your response.

I would but I'm out working and posting on my mobile phone. It will be several hours before I am at my PC. Can you try yourself and post what you think might work?
Please upload to this website, not link to somewhere else.

Thanks

Ok thank you I will try and send the result here if founded.
I just don't found a direct pictures upload from my computer to this forum that's why I did this way...


As I haven't a license for simulation software I cannot test the circuit (and I don't have PNP transistor too ).
Is this one good ? Or at least closer of the solution ?

Thank you all again for your help.

Just wondering, why going through all that effort to power down the processor, while in deep sleep it uses <1 µA - so little it's less than the self discharge of most batteries. Those transistors may very well leak more current than a sleeping MCU.

It's because the leds consumes about 10mA each (when it's mount on the board)

Do you really have a 5V battery? I don't think I've ever seen one. Or is it a powerbank? In any case, if it is 5V, you can't connect it to the Nano's Vin pin. Vin is the input to the 5V regulator, and requires something like 7V to regulate properly. Instead, your 5V supply should be connected to the Nano's 5V pin.

In general, I think it's safer to have your switch connect the collector of the 2N2222 to ground to turn on the power. But that's just a personal preference.

The Pololu power switches do what you want.

No it's a 12v battery that have a 5v converter. So Do I need to put the converter voltage to 7v ?

I going to look at that switch but the goal is to achieve this only with transistors which might possible I think ?

There's no point in converting it twice. So I think the converter set to 5V is fine. You just need to connect it to the 5V pin, not Vin.

This is what I meant about the switch (mosfet instead of PNP, but the principle is the same). But it's not a major issue.

Your circuit looks reasonable, but you should take note of the comment by wvmarle in reply #10, there is no point to doing this, just use the processor's sleep mode. As for the LEDs taking current; turn them off before putting the processor to sleep!

gugzthargy:
It's because the leds consumes about 10mA each (when it's mount on the board)

The power LED of course you just remove... very easy to do. When you're at it, the regulator can go as well. Then the Pro Mini uses virtually no power when in power-down sleep mode.

I've seen several videos on this arduino sleep but it was always without the chip on the board. Is ther a difference between deep sleep and sleep ?

If I chose the deep sleep method I will need to wake the board on button presed that's it ?

Thank you all PerryBebbington, wvmarle ans ShermanP.

Does someone have a link to a topic of a deep sleep and led desactivte ?

Thank you all again for your help ! Have nice evening !

,

Power saving discussion.