Help! Simple MOSFET circuit not working consistently

I’m building a circuit that lights a 9W 12V MR16 LED bulb using a photointerrupter (GP1A57HRJ00F) via a transistor (D3328Z) and a MOSFET (IRLZ34NPbF).

The problem I’m having is that it all works fine for about 15 seconds – the lamp goes on and off as the photointerrupter is interrupted or not . But then it becomes erratic: the lamp stays off for a number of cycles, at first working for a few cycles in an ever shortening bursts, then just staying off, and not switching for a few seconds. Meanwhile, the MOSFET heats up.

If you let it sit for a few minutes, it works again as before. I figure it’s cooling down; I have no way of measuring the temperature other than touching it, but when it works it’s cool, and when it has stopped working, it’s hot, sometimes (if I push it to always being off), hot enough to burn skin (ouch!).

If you drive an LED instead of the MOEFET with the transistor output, it works fine indefinitely, so the problem seems to be the MOSFET.

I have attached a schematic (all the power comes from batteries; please forgive my not drawing the MOSFET correctly). Is there something I’m missing? Does anyone have any suggestions? It seems like such a simple circuit, but I’m not at all an electrical engineer, and don’t understand what’s going on.

Thanks in advance!

lampCircuit.pdf (1007.9 KB)

The NPN transistor shown is the wrong choice for a high side switch. The base voltage must by higher by 0.7V than the emitter voltage for conduction.

You don’t need it at all. Drive the gate of the IRLZ34 directly from a 5V source (e.g. pin 4 of the photointerrupter).

Thanks – that was the key! I made the whole circuit run on 12V , then eliminated the transistor, and drove the IRLZ34 directly from pin 4 of the iterrupter, and it seems to work fine. I am extremely grateful! :pink_heart:

Check if you have a pull-down resistor connected between the gate and source (ground). When driven by an intermediate transistor, the MOSFET gate capacitance can trap charge if there is no direct path to discharge it. That leaves the MOSFET operating in its linear region instead of switching fully on or off, which causes rapid overheating. A 10k resistor between gate and source usually resolves that issue. Also verify the gate-to-source voltage (Vgs) with a multimeter when active to confirm it reaches a sufficient voltage to keep Rds(on) low.