Electronic – Raspberry Pi Mosfet Switch

12vmosfetraspberry piswitches

I'm trying to set up a project in which the raspberry pi will turn on/off and on a 12V circuit. I've read that a MOSFET would be best but I can't seem to get the circuit to work. I'm using a 30N06 MOSFET, and this guide for reference. Before testing the entire circuit with a GPIO pin I wanted to test the switch itself, so I've connected the 5V raspberry pin directly to the gate of the MOSFET in an attempt to "turn on" the switch. My circuit looks like this currently:

current circuit

I must be doing something wrong though, since there is no current flowing in the 12V circuit. I have troubleshooted by running the 12V circuit without the MOSFET, as well as measuring the voltage from the raspberry pi 5V pin, and everything seems to function normally, so I am sure the problem lies in how I am connecting/using the MOSFET. I have also also found this guide online which seems to agree with my circuit, so I am extremely puzzled as to why it is not "turning on" (http://www.robertcudmore.org/blog/?p=181).

Any help or suggestions would be extremely appreciated.

Best Answer

In order to turn on the MOSFET, a certain voltage between its gate and source must be attained. In your case, you have an n-channel MOSFET, meaning that once the gate is driven to a higher voltage than the source, it will begin to conduct current between its source and drain.1

In order to do this the 12V circuit must not float with respect to the control circuit. You'll need the 12V circuit to share a ground with the Raspberry Pi in this case:

enter image description here

1 There's also a parasitic diode that allows conduction in the other direction regardless of gate voltage, but it's not relevant to this circuit as it is currently designed.