Relay Drivers
...

I think we have all the necessary knowledge to either build or go online and look at some schematics that have relays and understand how they work.

Custom Relay Driver (with BJT)
...

We can start by showing how to build our own relay driver and keep things relatively simple.

If the nominal current on the coil is less than 100mA (assuming that the relay is operating at 12V), you can use an off the shelf transistor like the 2N2222A (datasheet) that can handle a continuous collector current of 600mA. However, you should pay attention if you need heatsinks around it or not to dissipate the heat.

custom_relay_driver_schematic.png
Example
The Songle SRD-SL-C model relay has a nominal current of 37.5mA at 12V, the total power dissipated by the transistor will be 

On the 2N2222A datasheet we see that the transistor, operating at ambient temperature of 25 degrees Celsius, can handle up to 625mW (outside the package) and 1.5W (inside the package). In this case we are safe to use the transistor without heatsinks.

2n2222_maximum_ratins_datasheet.png

Simulation (Link)

Note: the relay circuit on the simulation, is not the Songle SRD-SL-C model. It is a random relay from Falstad to show the concept of operation.

Custom Relay Driver (with MOSFET)
...

If your relay uses a continuous current that makes the BJT require a heatsink, you should use a power MOSFET instead (for example the IRF630). The driver circuit is relatively identical, with some minor adjustments, since the MOSFET operates with voltage rather than current. The power MOSFET should also be TTL friendly, meaning the voltage to turn on/off the MOSFET should be between 3V to 5V.

You also need to pay attention if the power MOSFET needs heatsink or not. You can follow an example on how to perform those calculations on this article under the "Design" section.

Simulation (Link)

HiLetgo Relay
...

The HiLetgo relay uses the Songle SRD-SL-C model that I introduced during the "Speed of Operation" section. Since this relay can operate between 3V to 12V, the PCB board includes a level circuit driver to make the module flexible to interact with.

hiletgo_relay_schematic.png

hiletgo_block_diagram.png

The Relay Circuit Block:

The PCB board includes a diode (D1) across the primary circuit of the relay to protect the rest of the circuit from back EMF. The secondary circuit is a SPDT switch. The LED (D3) indicates when the coil is energized or not.

hiletgo_relay_circuit_block_schematic.png

The Driver Circuit Block:

The driver circuit has an optocoupler that allows turn on the relay with a high or with a low IN voltage. It has a PNP transistor to drive the coil with the required current and the LED (D2) indicates if you have power in the circuit.

hiletgo_driver_circuit_schematic.png

Connection with a microprocessor:

hiletgo_wiring_diagram.png

On the secondary side of the relay circuit, connect your load according to the desired behavior:

  • If you want the load to start with a open circuit, connect the load to the NO pin
  • If you want the load to start with a closed circuit, connect the load to the NC pin.

On the microprocessor side, you need to pay attention to how the driver circuit works.

Driver Simulation
...

In order to understand the behavior of the driver circuit, let's simulate the optocoupler with the jumper and the microprocessor interaction and remove the status LED and the PNP transistor for now. I will simulate the full circuit later.

hiletgo_driver_jumper_explanation.png

Falstad as an optocoupler module but it has only one LED inside, rather than two. But since we are just try to understand which of the LED's is working for different jumper configurations, using two diodes to simulate the optocouplers will be sufficient to understand the concept of operation.

Jumper on the High Setting (Link)

There is only one diode conducting at the time. On this setting, the diode on the left is going to turn on/off depending on the output pin state of the microprocessor. In this setting, the D+ pin can be connected to 12V and have the relay working at a higher voltage.

driver_circuit_jumper_high.gif

Jumper on the Low Setting (Link)

On this setting, we need be more careful on which voltages we pick for D+. For example, if D+ is left connected to 12V, the diode on the right will always be on.

driver_circuit_low.gif

For this setting, D+ needs to be always equal to the output voltage of your microprocessor, otherwise the diode will never turn off.

driver_circuit_low_2.gif

Full Simulation (Link)
...

Since the optocoupler in Falstad only has one LED, I will be setting the jumper to the low side so we can simulate the full circuit accordingly.

Gravity: Digital 5A Relay
...

Another popular relay in the Arduino community is the Gravity Digital 5A Relay.

gravity_relay_image.png

I will point out the protection and driver blocks in the schematic below, and I hope this guides you understanding how it works.

gravity_relay_schematic.png