Universal Relay Module

Here is the circuit of a do it yourself universal relay module for microcontroller projects. One advantage of this design is that it can work with both active-high and active-low TTL signals from the I/O of any microcontroller. The circuit is infact a powerful electromagnetic relay with rich galvanic isolation, rated for 240VAC operation. This is the type of relay you will need to switch mains powered devices. The relay will handle almost all devices used in homes, however, ensure that the power rating (VA) of the device to be connected with it is less than the actual power rating of the electromagnetic relay.

Universal Relay Module Circuit - Basic

As can seen from the above schematic, the design is centered around an ‘ac’ opto-coupler (OC1). Remember, an ordinary opto-coupler will not work with this concept. The 2-way jumper header (JP1) is for switching active-high (H) and active-low (L) input mode. As you might noticed, I/Os of most microcontrollers can only supply +5V (or +3.3V) and less than 40mA (20mA typical). So, you cannot drive a power relay’s coil directly from that output since 5V power relays usually require more than 50mA to energize the relay coil. This calls for a separate power supply (+5V) to the module in addition to the signal (IN) from microcontroller’s I/O which is used to drive the relay.

In the schematic, both the I/O drive voltage and the relay coil voltage are the same +5V, and hence there is no problem with active-low input because the voltage being pulled down by the I/O will not be more the 5V (actually the galvanic isolation is not very important here). But this is not the case for a 12V relay. If you want to to use a 12V relay driven by a 5V I/O, and you’re using an active-high I/O, there’s nothing wrong. But problems can occur if the relay is driven by an active-low signal because this may damage the concerned I/O or the whole microcontroller.

Shown below is the schematic revised for 12V relay operation. As you can see with the opto-coupler and a separate Vcc input (+5V from the microcontroller’s power supply), the I/O is perfectly isolated from the +12V relay voltage. This idea prevents the 12V being feedback to your microcontroller’s 5V I/O, when driven by the active-low signal.

Universal Relay Module Circuit

Pre-wired relay modules are very convenient for interfacing power relays for switching application in your projects. This module can be configured in two modes using the jumper headers. By default, the relay is controlled by an active-high signal. It also includes two visual indicators so you can see the power input and relay output status. A final point, most power relays commonly use silver alloy switching contacts hence are not suitable for switching very low currents (few milliamperes).This is because the power relays need a ‘wetting current’ to break through the surface film resistance and will not pass very small currents reliably!

Leave a Comment


    • Lucas: The second diagram is meant for 12V ‘load’ operation, i.e. to control a 12V relay by a 5V signal from the 5V microcontroller. As clearly mentioned, with the opto-coupler and the default Vcc input (+5V from the microcontroller’s own power supply), the I/O of the microcontroller will perfectly be isolated from the external VCC (+12V relay voltage). This trick prevents the 12V being feedback to the microcontroller’s 5V I/O, when driven by the active-low signal. Hope this helps!