Linux Format

Relay driver circuits

-

The Pi’s IOs generate 0V on a low and 3.3V on a high. The specified DPST relays need a DC coil voltage of 5.0V in order to switch, meaning that a driver circuit will be needed to boost the voltage of the Pi’s output up to 5.0V and drive the coil to switch the relay.

Building a driver circuit is straightfo­rward. First, grab a general purpose transistor such as a 2N3904. Then, create a circuit for the transistor that will allow it to run in the saturation region of operation during an ON (GPIO high). To do this, calculate the correct resistor value to obtain the saturation current needed and hook it up in series with the GPIO of the Pi’s output to the transistor’s base. Hook up the transistor’s emitter leg to ground. The collector leg will be hooked up to the coil’s low rail on the relay. The coil’s input of the relay will be hooked up to a supply of 5V. This is a generic transistor switch setup. When the Pi outputs 3.3V to the base of the transistor, the current will be enough (thanks to the calculated resistor value) to drive the transistor into saturation. This will then allow full current to flow from the 5V rail through the relay’s coil and then to ground. The coil in the relay will then actuate the mechanical switch controllin­g a higher load. Remember to incorporat­e a diode across the relay’s coil in order to eliminate back-EMF. This is a must as back-EMF has the potential to hurt the Pi.

Newspapers in English

Newspapers from Australia