There are many types of relays but the most commonly used ones are electromechanical relays. They are cheap, simple and provide very good isolation between the control circuitry and the connection.
The diagram below shows the inner workings of a typical electromechanical relay.
The control circuitry is connected to a coil in the relay, and when the relay is energized, it will create a temporary magnetic field that will cause the relay contact to close and complete the circuit on the other side of the relay (usually a high voltage circuit).
Relays usually come in a box shape, like the ones I got below.
On the left is a 5V relay and on the right is a 24V relay. What this means is that the relay on the left requires just 5V to energize the relay coil while the one on the right requires 24V. Depending on the application, a 24V relay may be used if lets say a microcontroller wants to detect whether there is a 24V input.
These relays are rated to conduct up to 240V AC @ 10A or 30V DC @ 10A.
Below is a schematic diagram on how to connect a relay, I used an LED to display whether the relay is turned on or off.
Since this is a very simple circuit, I built it on a donut board.
The relay requires 3 connections, 5V, Ground and an Output pin from a microcontroller. The two connections on the screw terminal block will be shorted when the relay is turned on.
I plan on using Bluetooth to control the relay, so I used a bluetooth module highlighted in my previous post.
I programmed the Arduino to turn the relay on or off upon receiving an ‘o’ input. It will also print out the status of the relay. You can download this code at the end of the article.
Here is a video demonstration :