1

Sorry for the confusing title, but here's my problem:

I'm trying to test out a 2N2222 transistor as a switch for a higher current (for a 4WD motor) with the Raspberry Pi B+, and I'm trying to use one of the GPIO pins to do so.

When I run the GPIO output high, nothing happens however. Yet, when I plug in the rail 3.3 V, it switches the transistor and runs the motor. I tested the GPIO pin with a multimeter, and sure enough it was outputting 3.3 V when high. My external power source is a 9 V battery, and I'm following a similar circuit design to HOWTO – Switching on/off a DC motor with a Raspberry Pi. I've tested the motors, transistor, and resistors just to be sure, and they work as expected. Is it because the amperage from the GPIO pin isn't enough for the transistor?

Extra info: the motors are supplied from the Tamiya dual motor gearbox and, combined, pull 2/3 of an Amp (if I remember correctly), which is why I use an external supply. I also have tried it with a 5 W external power supply too, with the same result.

Sorry if this may sound silly, I'm still learning as I go! Any help is appreciated.

4
  • 1
    That is a lousy circuit. Apart from missing back emf protection 75% of the power is jut heating up the transistor. See elinux.org/RPi_GPIO_Interface_Circuits
    – Milliways
    Mar 25, 2016 at 6:01
  • As @Milliways suggests, ditch that circuit and build something safer. Your question reminded me of another question to which I wrote a long-winded answer concerning relays, back-EMF, etc. Maybe that'll give you some inspiration
    – jDo
    Mar 25, 2016 at 11:37
  • @Milliways Okay, I will try the circuit to up the load output from the GPIO pin that you suggested from the link. But shouldn't the circuit I mentioned, although dangerous, still work though? Because the GPIO pin ,similar to the one suggested by the link, is supposed to switch the transistor a similar way, yet it doesn't for me? Thanks for your help by the way!
    – John Does
    Mar 25, 2016 at 16:51
  • @jDo I will make sure to read up on that, might be useful in my current situation. Appreciate it!
    – John Does
    Mar 25, 2016 at 16:53

1 Answer 1

1

Make sure you have connected the ground output from the pi to the motor and ground connection of the external supply.

Measure voltage across the base/emitter junction. Should be 0.7 voltage when pin 7 is high. Also measure the voltage across the motor.

You should check the voltage at pin 7 is changing 3.3 to 0.

Base current should be 2.6V/1000 so 2.6mA. You should be able to measure this with a multimeter. If you have current flow but it's not switching, try a smaller resistor on the pin 7 to base connection maybe 500 ohms to double the current. If you have two 1K resistors, put them in parallel.

1
  • Double checked the connections as you said, and it worked! The bases weren't together. I also built a safer circuit thanks to @Milliways. Appreciate the help everybody!
    – John Does
    Mar 26, 2016 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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