I want to drive a old phone ringer solenoid bidirectionally (20 Hz) using raspberry Pi GPIO pins. I am new to electronics, but I thought a H-bridge design would work to do this:

H bridge

The solenoid is 500 \$\Omega\$, dont know the inductance. For the transistors I plan to use BC548C's. I will use the GPIO pins to provide the 20Hz signal. My questions are the following:

  • In equivalent unidirectional circuits I've seen flyback diodes across the solenoid. Do I need to use this? In my case, where I want to drive the solenoid in both directions, a TVS like http://www.fairchildsemi.com/ds/P6/P6KE150A.pdf?
  • Do I need to use optoisolators or equivalent to protect the RPi?
  • Did I correctly assume that I need to connect RPi ground to solenoid power ground?
  • Are pull-down resistors needed, if so what would be a good resistance value? 50k?

And, in general, will this design work or are there better alternatives?


I've redesigned as suggested with P-channel and N-channel MOSFETs. Also I added 2 NPN transistors type 2N2222 (level translators?), which can switch with 3.3v and work with the RPi.

New H bridge with N and P channel mosfets

As I understand it now, when the GPIO's are 0, the pull-up resistors keep the P-channel MOSFETs (Q1,Q2) off and N-channel MOSFETs (Q3,Q4) on. When GPIO 1 is switched to high, the gates of Q1 and Q3 are pulled to ground and therefore Q1 switches on and Q3 off, allowing current to flow from left to right through the solenoid. GPIO1 low and GPIO2 high to invert.

Now, I'm not sure on which MOSFETs to pick. I've spend hours looking through online cataloges and can barely see the forest through the trees anymore. In any case, I found BSS84AKW for P-channel and NX7002AKW for N-channel.

(Please google for data sheet I can't post more than 1 link yet)

Are these the right parts for the job? I've selected them mainly because of the low Vgs threshold voltage, since I work with logic level voltages. Is it then also possible, with these or other MOSFETs, to operate this without the Q5,Q6 transistors, or does that only work if GPIO voltage is equal to drive voltage? (here 3.3V vs 5V)

  • \$\begingroup\$ The Pi GPIOs only pull up to 3.3 volts, so your circuit can only pull the positive side up to ~2.7 volts. This probably won't operate the ringer (even if the GPOIs went to 5 volts) as telephone ring voltage is normally 90 volts or so, if I recall correctly. \$\endgroup\$ Commented Mar 31, 2014 at 15:47
  • \$\begingroup\$ @PeterBennett Yes, I also read somewhere that normal voltage is 90V. However, I tested my ringer with 5V which worked. So then all I need to do is alternate it with 20 Hz. \$\endgroup\$
    – xyzzyqed
    Commented Mar 31, 2014 at 16:15
  • \$\begingroup\$ Hi @xyzzyqed, I'm currently doing a project that needs almost exactly the same set-up as yours with a bi-directional solenoid (although mine needs 80 Hz) and was wondering if your latest updated circuit drawing worked out for you. This post is the only piece of information for this specific problem I could find. Appreciate any help, thanks! \$\endgroup\$
    – mDroidd
    Commented Apr 14, 2018 at 14:01

2 Answers 2


I think it's important to mention that as the circuit stands it won't work in other words your basic idea is not OK: -

  • When the lower transistor turns on, the base voltage to ground will be about 0.7V and the associated upper transistor will not turn on hardly at all - maybe you might get a couple of mA through it.
  • If the above problem is solved the upper transistors might see 3.3V on their bases and this means the emitter voltage will be at a lowly 2.6V for any decent current into the load.

Both of these are reasonable show-stoppers so go the sensible route and use P channel mosfets for the upper devices and N channel mosfets for the lower devices. I'll not labour this because the question has been marked accepted. Alternatively buy a H bridge IC like the DRV8803

  • 1
    \$\begingroup\$ Good catch, Andy, the implementation shown doesn't work, you would need resistors in series with each of the bases, and a level translator or opto if the GPIO only puts out 3.3V. \$\endgroup\$
    – John D
    Commented Mar 31, 2014 at 16:49

The basic idea is OK, though the implementation isn't. You need diodes across each of the transistors (cathode to collector) instead of the TVS. You need resistors in series with each of the bases, and if the GPIO only puts out 3.3V you would want a 5V level translator. You might be better off using P-Channel MOSFETs for the top devices and N-Channel FETs on the low side. Then the body diodes in the FETs will take care of the inductive current. (Use logic level FETs.)

You don't need opto-isolators, but isolation might be a good idea since it will protect your GPIOs in case of problems during debug. Your switching speed (20Hz) is low enough that you don't need super fast drive.

Without isolation and separate supplies you will need to hook the two grounds together.

If you use FETs, large value pull-down resistors from gate to source are not a bad idea. If you use opto-couplers depending on the type you may need additional circuitry to interface to the FETs or bipolars correctly.


Your Answer

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

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