Soft power and Arduino nano

I want to start my arduino nano up with a momentary push button, then be able to use a digital out on the nano to power off again, and run the project off battery.

There seems to be quite a few guides out there, many using a single N-chanel MOSFET, all along the same lines as this:

I can not get this (or the similar variants) to work? Does anyone know what could be going wrong? Each time I connect a battery, the arduino powers up and stays up before the button is pushed. For compactness I am using a 9V rechargeable but also have tried a 6v (4xAA) battery.

Sketching out the circuit myself, I get:
Google Photos
This seems to be a textbook example of a MOSFET switching circuit.

If I am understanding MOSFETs correctly, this powers up before the push button is pressed because there is a current flowing through the arduino from Vin to D4, putting a voltage between G and S on the MOSFET and powering itself without the button.

Is that right and is there any way to change this? A large resistor on D4 or perhaps reduce the size of the 330K? Due to a misreading error, that was originally just 330 ohm, which did give the same problem.

Hi,
OPs diagram.

You need to high side switch, that is switch the positive supply ON and OFF.
The circuit you have there is like trying to pick yourself up by your boots.

Tom... :slight_smile:

Hi,
This link to a previous forum thread might help.

http://forum.arduino.cc/index.php?topic=285286.0

With this suggested circuit.
1feb6d24ab232f0eec95bb2d05252ff930f9239e.jpg

Tom… :slight_smile:

TomGeorge:
Hi,

You need to high side switch, that is switch the positive supply ON and OFF.
The circuit you have there is like trying to pick yourself up by your boots.

Tom... :slight_smile:

Thanks, though I'm not sure what that means!

I also don't understand why the person who did the tutorial was able to get this working on his video but it fails for me.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
What MOSFET are you using?

Can you post a copy of your code as well.

Also a picture of your project so we can see your component layout.

Do you have a DMM to measure some voltages.

If you are using one of those tactile buttons in the diagram, make sure you have it the correct way round.

Thanks.. Tom.... :slight_smile:
PS I'm off to bed, 11:20pm here.

Copy of circuit as posted earlier:

Code is very simple

int count=0;

int LED=13;
int BUTTON=4;

void setup() {
  // put your setup code here, to run once:
  pinMode(LED, OUTPUT);
  pinMode(BUTTON, OUTPUT);
  digitalWrite(BUTTON, HIGH);

}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(LED, HIGH);
  delay(1000);
  digitalWrite(LED, LOW);
  delay(1000);
  count++;
  if(count>5) {
    digitalWrite(BUTTON, LOW);
  }

}

Assuming DMM = Digital MultiMeter then yes I have one.

I am using a tactile button, but it is a 2 pin button, there is no right and wrong way. Even with it removed, it still powers up before the (removed!) button is pressed.

The photo of the component layout looked too cluttered to see anything particularly clearly but if someone thinks it will really help then I will see what tidying I can do and post that.

Just one thought, the places I have seen this circuit used have used an Uno. Is there something different about the Nano when powered off?

Doing a little experiment there is a resistance of 1733 ohms between Vin and the digital pins when powered off. However that drops to 727 ohms between digital pins and +5V. +3v3 seems to be 1.6Mohm. By using Vin, do I have the wrong resistor value at the bottom? If so, how should I calculate what to replace the 330k resistor with?

Your circuit won't work, because there is a pin protection diode on D4.
That pin can never get more than 0.7volt below Arduino ground.

If you fill in the numbers when the Nano is OFF:

V-in = 9volt, GND= 9volt, D4 = 8.3volt.

That 8.3volt will power the gate throug the voltage divider, and will turn the mosfet ON.

A two-transistor high-side switch is needed (post#2).
Leo..

Thanks, I will give that a try. I was hoping I could get it working with the parts I had. Looks like I need to splash out another £3!

Do all the digital IO pins on the nano have the diode pin protection?

Hi,
Just a clean up of the circuit.

Tom.. :slight_smile:

DaveHKent:
Do all the digital IO pins on the nano have the diode pin protection?

Yes.

Thanks for all the help both of you.

As a final (hopefully) question, do the following components sound suitable?:
IRFU5305 P-channel Hexfet Power MOSFET
http://www.hobbytronics.co.uk/electronic-components/mosfet/irfu5305-p-mosfet

BC548B NPN General Purpose Transistor
http://www.hobbytronics.co.uk/electronic-components/transistors/bc548-npn-transistor

The fet is not logic level, but that is not a problem in this case (9volt drive).
Small transistor is also ok.

R2 in the diagram (post#9) can be 10k.
Leo..

DaveHKent:
Thanks for all the help both of you.

As a final (hopefully) question, do the following components sound suitable?:
IRFU5305 P-channel Hexfet Power MOSFET
http://www.hobbytronics.co.uk/electronic-components/mosfet/irfu5305-p-mosfet

Should do just fine - but 31A is a bit overkill for this application. Vgs(th) is pretty high, so you can't switch 5V circuits with this. Check whether they have the IRL version of the same, that's logic level and switches on properly at 5V. For this application you have -9V Vgs so you're fine with this one.

BC548B NPN General Purpose Transistor

This is a really common small signal transistor, great to have around for many different projects, so don't worry about them coming in 10-pack.

Thanks. I usually buy components in a bundle anyway so having 10 or 20 is not bad.

Would a FQP3P20 be a better choice? 2.8A with a -5v trigger voltage?
Data sheet:

Worse, in many ways. Read the datasheet.
Vgs(th) is even higher (-3.0 to -5.0V). Rds(on) is very high at 2.06 Ohm.

Try digikey.com or mouser.com to select parts.

I thought -3.0 to -5.0 would be better as 9v easily tops that and buying a pack means I have some spare MOSFETS that can be used in other projects.

What should I be looking for for the Vgs?

Reading up more (and getting more confused), is the Vgs the voltage that the MOSFET will turn on, or the voltage the MOSFET will turn off?

There seems to be a general guide that for most arduino nano applications they will draw a max of 40mA, so is that (or a bit higher) a suitable value for the continuous drain current?

Drain source voltage needs to be above 9v, as I'm not going over this?

That just leaves the threshold voltage calculation, which I thought was -9v (or -5v if I use in other applications)

That FQP3P20 is worse, with a Vgs(th) of 3-5volt.
Vgs(th) is often misunderstood.
It's the (threshold) voltage that the mosfet just starts conducting. The "turn-on/off" point.
To turn a mosfet fully on, you need at least 2-3 times that voltage.
So this mosfet turns off at about 3-5volt, and is fully on at 10-15volt.
A logic level mosfet has a Vgs(th) of about 2volt.

For this application, a TO-92 mosfet like the BSS250 BS250 would do.
Leo..

DaveHKent:
Reading up more (and getting more confused), is the Vgs the voltage that the MOSFET will turn on, or the voltage the MOSFET will turn off?

Vgs = the gate/source voltage.
Vgs(th) = the gate/source voltage where first conduction starts, i.e. the bare minimum.

You want your MOSFET to be completely open at -9V (negative as it’s a P-channel). So a Vgs(th) at 2-4V as your first suggestion has, would do.

Wawa:
For this application, a TO-92 mosfet like the BSS250 would do.

I think you have an S too many there. There is a BS250 MOSFET out there. But again very high ON resistance of about 3 Ohm. I’m used to seeing much smaller values for that, <0.1 Ohm, for the n-channel MOSFETs I’ve been looking at so far.