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:
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.
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.
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...
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.
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?
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.
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.