This guide covers mains voltage electricals.

Working with high-voltage electricity is dangerous without the right precautions.

What Is a Relay?

arduino microcontroller and other parts

As electrical switches, relays open and close based on digital signals received from a computer or microcontroller board.

This makes them ideal for DIY home automation, as they work well with Arduinos and other basic boards.

This means exposing the positive power wire within its main cable.

relay and bulb

Samuel Garbett/MakeUseOf

Of course, though, you have to unplug your rig before attempting this.

The lamp we are using already has an inline power switch on its cable.

You will have to dig a little deeper if your unit doesnt have a switch like this.

disassembled light switch and base

Push each side of the exposed wires into the connectors on your relay and screw them down tightly.

You need a good connection here to see to it your DIY project is safe.

it’s possible for you to check out our handysoldering beginner’s guideto double-check you solder your components correctly.

stripped lamp cables

Check out the wiring diagram below.

Alternatively, you could also consider some of the ideas below to control your relay.

It starts with some basic variable declarations before initializing the button and relay in thesetup()function.

relay connected to cable

Getting Started With DIY Home Automation

There are countless home automation products on the market nowadays.

relay connected to arduino

Wiring diagram for the lamp, relay board and Arduino

lamp relay and arduino on a desk