Do not construct circuits involving mains supply without close expert supervision. You risk electrical shock which can be fatal.
A relay is normally used to switch a high-power circuit such as mains power. The relay is controlled with a low-power circuit.
Inside the relay is a coil that is energised by a low-power supply, such as a 5V battery. When the coil is energised, the switch moves from NC (normally closed) to NO (normally open). This type of switch is known as an SPDT (Single Pole Double Throw) switch.
Therefore, you can use a low-power circuit such as the output pin from an Arduino to control a high-power circuit.
PART 1: OPERATION OF THE RELAY
The relay module includes a transistor driver circuit shown below. This enables the Arduino output pin to control a larger output current to drive the relay module. Otherwise, the Arduino output pin can only supply a maximum current of 40mA, which is enough to turn on LEDs but not enough to energise the relay’s coil.
On the other side of the relay module are the pins NC, COM, and NO.
- COM is where you connect power from the mains. This is the power supply that will drive your high-power circuit.
- NC is always connected to COM when the relay is not turned on. When the relay is turned on, mains power is disconnected.
- NO is not connected to COM when the relay is not turned on. When the relay is turned on, mains power is connected.
PART 2: USING THE RELAY WITH ARDUINO
STEP 1: Connect the relay as shown below.
STEP 2: Here are examples of how to control the relay. The program turns the relay ON for 1 second and OFF for 0.5 seconds repeatedly.