Let’s take a look at a new component called a relay.
A relay has 5 terminals, two of which are connected to a coil which forms an electromagnet. The image above shows what the inside of the relay looks like and the end terminals are connected directly to the large coil in the centre.
The relay also has 3 other terminals – one is the common terminal and the other two are the outputs. It can switch between the two outputs depending on if the electromagnet is ON or OFF. When the magnet is OFF, the common terminal is connected to a pin called N.C. or normally closed. While it is connected to the other pin called N.O. or normally open when the magnet is switched ON. The magnet can be switched ON by placing the rated voltage across the coil – in this case, 3V.
There’s one more thing we need to know before we build the circuit. Just like a capacitor tends to hold on to its charge or voltage, a coil tends to hold on the current flowing through it.
When a circuit containing a coil is switched OFF, there needs to be a path for the current to continue to flow or else there will be a sudden spike in the voltage which will destroy the electronics connected directly to the coil. This spike is called back-EMF. The electromagnet is made up of a coil and coils have something called inductance.
A diode is one such component that can be used to suppress this back-EMF. A diode allows current to flow in only one direction and blocks it in the other. Current flows through the diode when it’s anode is positive compared to its cathode. An LED is a special kind of diode that emits light when current flows through it. Just like an LED, a regular diode also has a forward voltage drop when current flows through it.
Take a look at the simulation above. We have a voltage source connected across the coils of the relay along with a diode in parallel with it. When the switch is closed, the relay is activated but no current flows through the diode as it is reverse biased.
When the switch is opened, the relay coil is still energised as the current can flow through the diode. This current decreases very quickly switching OFF the relay.
The schematic diagram is shown above and the section to the left is very similar to our PIR circuit. We simply connect a relay and diode to the output. The relay is not exactly breadboard-friendly, but you can twist the terminals to insert it. Another option is wrapping a jumper wire across its terminals.
Let’s use the breadboard layout to build and test the circuit.
When motion is detected the transistor will switch ON. This will switch ON the LED and the relay. There is a slight audible click when the relay switches ON and this serves to confirm that it has switched ON.
A relay can be used to control an independent circuit. For instance, you can use this relay to activate a mains operated light or any other device within the operating limits. We wanted to introduce the concept of relays as they are commonly used. Please do not work with mains electricity if you are starting out as it can be fatal. At the very minimum, please make sure you have a GFCI or RCD installed before working on any AC mains equipment even if it is a simple lamp.