How can a reed switch and a mosfet be used to cut power to a microcontroller

MaxHeadRoom

Joined Jul 18, 2013
30,557
You could do it a couple of ways, one would be hold the microcontroller in constant reset, when the SW is activated.
If the capacity of the SW is sufficient, it could be used to cut the power pin of the micro direct.
 

MisterBill2

Joined Jan 23, 2018
27,159
Really, another electrically simple scheme will be to arrange a limited motion for the float so that when the water level is a bit above the bottom that the magnet is held in a position to close the reed switch, so that only the last bit of dropping water level opens the reed switch. Then just have the reed switch in series with the power feed to the micro. That is the very simplest, zero power scheme I can come up with. Just adding a small amount of mechanical complexity.
 

Thread Starter

FranciscoB

Joined Feb 8, 2014
138
I have a float switch that consists of a reed switch that closes when a magnet gets near it. I would like to cut off the power to a microcontroller when the float switch is at the bottom of the water barrel. Maybe use the reed to pull the gate of the n-channel mosfet to ground?
Very good idea, thank you. I have microcontrollers with accessible chip-enable and reset pins, unfortunately it's not the case with this one but I will be using your idea in the future.
 

Thread Starter

FranciscoB

Joined Feb 8, 2014
138
Really, another electrically simple scheme will be to arrange a limited motion for the float so that when the water level is a bit above the bottom that the magnet is held in a position to close the reed switch, so that only the last bit of dropping water level opens the reed switch. Then just have the reed switch in series with the power feed to the micro. That is the very simplest, zero power scheme I can come up with. Just adding a small amount of mechanical complexity.
English is not my first language but I think this is almost exactly the setup I have currently. However, in my case the float slides all the way to the top when the barrel is full, which could actually get it stuck against the water feeding tube, therefore I'm going to limit the travel as per your suggestion.
 

Attachments

MisterBill2

Joined Jan 23, 2018
27,159
Consider again the scheme proposed for the magnet to hold the reed switch closed until the tank is almost empty. That is assuming that the reed switch is normally open held closed by the magnet, which is the common type of reed switch. If a normally close reed switch is available the arrangement will be a bit different.
In either case, the switching will be direct, no need for any active device circuit.
 

MaxHeadRoom

Joined Jul 18, 2013
30,557
As I suggested, using the Micro reset pin, requires virtually no current and allows the micro to come back on line without (re)-booting up.
 

MisterBill2

Joined Jan 23, 2018
27,159
OK, MAX has just described where to connect the reed switch. And if that input uses a low=true scheme only a reed switch and pull up resistor are needed.
 

AnalogKid

Joined Aug 1, 2013
12,043
Maybe use the reed to pull the gate of the n-channel mosfet to ground?
Close.

1. Change the FET to a p-channel type. Preferably a logic-level type.

2. Swap the drain and source connections.

Now, when the gate is pulled low by the switch, the drain will be pulled up to the source, which is at 5 V.

ak
 

sghioto

Joined Dec 31, 2017
8,633
[QUOTE="AnalogKid, post: 1925402,
Now, when the gate is pulled low by the switch, the drain will be pulled up to the source, which is at 5 V.
ak[/SIZE]
[/QUOTE]
The switch would need to be NC to provide power.
If the switch is NC then the transistor isn't needed.
 
Last edited:

Thread Starter

FranciscoB

Joined Feb 8, 2014
138
This setup is working consistently.

The microcontroller in this photo was used because it's easier to breadboard. The microcontroller I will be using in my project is the posted above, which fundamentally works the same way but with a different amount of pins broken out.
 

Attachments

BobTPH

Joined Jun 5, 2013
11,463
The picture shows a switch labelled RST. So you would not need to connect directly to the micro pin. You could remove the switch and replace it with connections to the reed switch. Or even leave the switch in and add the reed switch in parallel if that is easier.
 

Thread Starter

FranciscoB

Joined Feb 8, 2014
138
On some occasions a simple mechanical solution will remove the need for a complex electrical solution.
The power of covfefe made me realize how much straightforward your suggestion was. I simply had to move the reed 5cm up the slider and place a limiter for the buoy. This way the microcontroller's path to ground is cut when the buoy reaches the bottom end.

Thank you again
 

Attachments

Top