0
\$\begingroup\$

I am a beginner when it comes to electronics so I would appreciate your help with a simple project I am working on and have been struggling with for several days.

The idea is that I have a PIR Sensor outputting to GPIO 24 on my Pi. Via a python script, I would like to switch on a 12-volt LED strip with its own external power supply. I am able to see when motion is detected via the script, so that is working fine. The issue however is that I am not able to properly use my mosfets to act as a switch. In order to take it step by step, for now I am trying to output signal to my mosfet Gate via GPIO 24, and manually alter the PWM via terminal (instead of using the PIR output).

My scheme is similar to this: https://screen.sh/cAaSbZiM - however not using the battery, and using the GPIO 24 output instead of PIR.

I have tried this with a IRLB8721 mosfet, but realized it needs a higher voltage than what the GPIO can provide. The most suitable one I could find then was the IRF3205, seeing that it is used more frequently with Raspberry PI/Arduino applications, but unfortunately this is also not working. It seems like my GPIO voltage is still too low.

Alternatively I have a couple of 2N3904 transistors available but I am not entirely sure how I can use these without frying them.

I have noticed that when using the IRLB8721, my LEDs are always on, and I am not able to switch them off. I did make sure not to mix up the Drain and Source, yet still not working.

Could you please guide me in the right direction? I am not able to get any other components for another week, so I am stuck with a diode, couple of 1kOhm resistors, and these 3 types of transistors/mosfets/ Is there anything I can do to fix this?

I have looked this up extensively and tried it on my breadboards but with no success. Only lead I have is pointing to a fairchild mosfet which I am not able to get to for weeks.

Thank you.

\$\endgroup\$
  • \$\begingroup\$ This website has a schematic editor. \$\endgroup\$ – DKNguyen May 22 at 21:55
  • \$\begingroup\$ IRLB8721 has max Gate threshold voltage of 2.25V, so it should switch on with 3.3V (datasheet suggests a 'typical' part can switch at least 2A with 3.0V on the Gate). "I have noticed that when using the IRLB8721, my LEDs are always on" - insufficient Gate voltage should cause the LEDs to not turn on. Either your FET is fried or the circuit is wired wrong. Show us a photo of your setup. \$\endgroup\$ – Bruce Abbott May 22 at 23:06
0
\$\begingroup\$

What made you think the IRF3205 was suitable? It is not a logic level MOSFET. For use as a switch, ignore the gate threshold voltage. This is the gate-source voltage where the MOSFET just barely starts to conduct. You don't care about that. You care about the MOSFET conducting as much as possible so instead of gate threshold voltage, look at the gate-source voltage used to achieve the desired RDson.

You need a 3.3V logic level MOSFET so the 3.3V on the RPI GPIO can actually turn it on and off.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thank you for the explanation. I will look for such mosfets. In the meantime, would it be possible to use something like the 2N3904? \$\endgroup\$ – orange orange May 22 at 22:12
  • \$\begingroup\$ Yes, but you need to put a resistor in series with the base since the base-emitter junction is basically a diode and would short-circuit the GPIO if you did not. \$\endgroup\$ – DKNguyen May 22 at 22:16
  • \$\begingroup\$ While I would like a direct answer answer to what kind of resistor I need, I would also like to learn. Is there any resource that would teach me this? From other sources I've understood that a 10kOhm resistor would suffice for this setup, but I cannot be sure of that. Please excuse my lack of knowledge, I am trying to learn and trying to get this little experiment to work, so if I can get to a quick way of using the 2N3904 then that would be great. I have a couple of 1kohm resistors (~15) \$\endgroup\$ – orange orange May 22 at 22:32
  • \$\begingroup\$ You could just look up using BJTs as switches. You would use the minimum Beta or Hfe of the BJT to calculate just how little base current you can get away with to fully turn the BJT on. Voltage across the resistor would be 3.3V - 0.7V (voltage applied by GPIO minus the voltage drop of the B-E junction). You can use that to calculate your the current through the resistor with V=IR. \$\endgroup\$ – DKNguyen May 22 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.