Internet of Things – Like Lamp

Today I will show you how to control anything that is powered with normal electricity. To make it simple, I will build on my previous example of making a LED blink each time someone gets a like on Facebook, but this time I will make a normal lamp blink instead.

Let me start off with a WORD OF WARNING. Normal household electricity is dangerous, and it’s not something that anyone should play around with. If you are not experienced dealing with normal electricity and are absolutely sure you know what you are doing, I advice you not to perform this lab, but rather watch how it’s done as a theoretical learning experience.

As I mentioned in the beginning of the video, this lab build on the ones in my previous video, so for more details on the code, please see that video. If you did the lab from the previous video, and that code is still in your Arduino Yun board then you can just concentrate on the hardware this time.

Here you can see the needed hardware, and in addition to the Arduino, the important component is a relay module. It’s a nice piece of hardware that can open or close an alternating current (AC) that is used in normal electricity, and it is controlled by a low power signal, such as one that an Arduino board can supply. You also need three jumper cables of the kind that have a male pin at one end and a female at the other. You also need a normal extension cable that can be manipulated to allow the relay to control the current, and a lamp that you can connect to the extension cable.

To setup the hardware, you should start by disconnecting everything from its power source, and each time you want to change something, make sure to always do this first. Then you connect the Arduino ground (GND) to the ground (minus) on the relay, and it’s a good habit to always use a black jumper for ground. Continue by connecting the 5V on the Arduino to the power (plus) on the relay, and a good habit here is to use a red jumper. Now you connect pin 13 on the Arduino to the signal (S) pin on the relay. That’s what’s needed for controlling the relay. If you like, you can connect the Arduino to the power, and after a while, the LED on the relay should blink with the same frequency as the LED on the Arduino board. Don’t forget to remove the power again before you continue.

Now we are ready for the lamp, and the easiest way to do it, is to remove the outer isolation somewhere in the middle of the extension cable, but make sure that you leave the inner isolation on each of the cables intact. Identify the ground cable (it’s usually the one with the two colors green and yellow), and then you can choose to cut any of the other cables. Remove some of the isolation on each cut end, and the end that goes to the power supply should go into the middle port of the relay (usually called COM), and the other end should go into the NO port of the relay. Now it’s time to test it, and start by connecting the Arduino to the power, wait for the LEDs (on both boards) to start flashing, and then KEEP VERY CLEAR from the whole setup when you connect to the main power and while it’s connected.

Using this technique you can control anything that is using normal electricity, and that can take your Internet of Things projects to new levels.