# Driving Relays with CMOS and TTL Outputs Calculator

This calculator will help find a suitable switching transistor, and provide a value for the *base resistor* that will sufficiently saturate the transistor. It is in three sections, and the first section will find the correct transistor providing you with ideal values for the
*hFE* and *collector current* parameters of a suitable transistor. In the second section, you must choose a transistor, which has a collector rating that is higher than the calculated value. It must also have an hFE rating that is higher than the calculated value but the closest. Finally, in the third section, you enter the hFE value of your chosen transistor, and it will provide you with a suitable value for the base resistor.

## Calculate Suitable Transistor

- Enter the supply voltage
**Vcc**in volts for your circuit. If your relay coil needs five volts then your supply voltage needs to be the same amount obviously. - Enter the relay coil resistance
**RL**in ohms. You will find this information in the documentation for the relay that you are using. - Enter the drive current
**Id**in amps that you would like to dedicate for driving the transistor.

## Choose a Transistor

NPN (TO-92) | Ic Max (mA) | hFE Min | Ic Min (mA) | hFE Max |

PN2222A | 1000 | 35 50 75 100 |
0.1 1 10 150 |
300 |

P2N2222A | 600 | 35 50 75 100 |
0.1 1 10 150 |
300 |

BC337 | 500 | 100 | 100 | 600 |

A suitable transistor is one that has an hFE and Ic rating *higher* than that calculated. If a suitable transistor is not on this list, then you will need to consult your data books to find one. An hFE of 100 usually works for most general-purpose transistors.

## Find Base Resistor

- In this final part, enter the minimum
**hFE**value you have chosen. This value has to be higher than that calculated above.

## Standard Resistor Value

Once you have a value for the base resistor RB in ohms, you need to consult the standard resistor values chart to find the nearest match.

## This Article Continues...

Raspberry Pi GPIO: Driving a Relay using a TransistorDriving Relays with CMOS and TTL Outputs Calculator