# Replacing a switch with a transistor

I am working on a project on the Raspberry Pi, it is a bit experimental as I am learning the electronics side as I go along... please edit out any problems with terminology.

My aim is to replace a switch with a transistor on an existing circuit, so I can use the 3V3 output from a GPIO pin on the RPi to control the open/close of a switch on an existing circuit.

I used a multimeter to test the voltage through the switch (from one + to -) which is 3V. I created a circuit on a breadboard which uses a BC547B transistor to replace the switch, connecting the + and - to the Emitter and Collector, with Base acting as the switch (3V3 output through a resistor). When I connect the Emitter and Collector to the transistor the reading is only 1V8.

The circuit seems to work, but with intermittent results. Is this due to the loss of voltage when using the transistor? Will I need to design around this or can I just use a different transistor? I just used one I had from another project without really knowing if it would work at all.

Edit;

I changed the circuit so that the voltage through the transistor came from the 5V pin on the RPi, and it worked perfectly. However, this is a power pin and not controllable via software, so it is not a solution, just evidence that the transistor is the problem. I think its time to start reading again.

• Can you tell us what the load is and its operating voltage and current? – Bruno Ferreira Aug 26 '12 at 23:16
• I dont really know how @BrunoFerreira – AnthonyBlake Aug 27 '12 at 12:22

Bipolar junction transistors, due to their nature and operation, tend to have a relatively large forward voltage. Field-effect transistors use the depletion or doping zone to pinch the current pathway closed or lever it open and so have a much lower forward voltage. They are much more sensitive to voltage surges such as those caused by static electricity though, so it is advisable to always use static protection when handling them.

• It looks like I need to do some more reading. I prefer experimenting but hey. – AnthonyBlake Aug 27 '12 at 12:21

You are likely dropping some voltage across the VCE of your transistor. In order to have a nice closed switch, I would look to FET type transistors (very low VDS drop) and or control a reed relay type switch via transistor control.

connecting the + and - to the Emitter and Collector

I hope that's not + to emitter and - to collector, because that would explain why it doesn't work for 3.3 V. The emitter should go to ground. Though this is probably not the problem, since it works for 5 V. The best explanation may be that you don't drive the base with enough current to saturate the transistor. Driving with 5 V and the same resistor gives you twice as much base current, so that's a possibility. Also a possibility is that the RPi can't even supply enough current for the transistor. In that case I'd say it sucks.

Swapping the BC547B for a MOSFET will solve that. MOSFETs are voltage driven, not current driven like BJTs. They just need enough gate voltage to activate, they hardly need any current (usually less than 1 µA). You have to make sure to select a logic level gate FET, which already will switch on with a logic level as low as the RPi's 3.3 V.

Many FETs will be suitable, though you will find more SMT types than PTH. The si3460DDV, for instance, will drive several amperes at only 2 V gate voltage and has an on-resistance of 32 mΩ, so it won't dissipate much power: even a 2 A current will only cause 128 mW dissipation.

You could also try and move your BJT to the saturation region and that will give you a VCE of around 0.3V, most likely you are now working on the active region.

• The RPi probably can't supply enough current to push it into saturation. – Ignacio Vazquez-Abrams Aug 27 '12 at 4:06