Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame
Are you ready to start controlling the world around with your Internet of Everything device? Ever wanted to turn on a lamp or open your garage door but didn't know how to interface with it? It is easier than you think when you use relays! Relays allow you to control high-powered electronics with low-powered signals from devices such as Arduino or Raspberry Pi.
What Is a Relay?
Think of a relay as an electronic light switch. To turn the light on, flick the switch up. To turn the light off, flick the switch down. A light switch simply closes (or completes) an electrical circuit to turn on a light and opens (or breaks) a circuit to turn off the light. A relay does this same exact thing except that the switch is powered not by hand but by a low-power signal. There are different types of relays and they differ by the types of poles and throws, as explained in the following two diagrams.
Figure 1: Switch Diagram
Figure 2: Relay Diagram
Pole and Throw
Pole and throw refers to how many inputs and how many outputs there are, essentially. A common type of relay is called Single Pole Double Throw, written as "SPDT." This means that there is one incoming path and two possible outgoing paths, depending on the low-level incoming signal. One of the paths is called the "normally closed" path; this means that, without power the circuit is closed. The other path is "normally open" meaning that, when no power is applied, the circuit is open. Figure 3 shows the different types of pole and throws available for relays.
Figure 3: Types of relay configurations
Why Use Relays?
The reason for using relays is simple. A device like an Arduino or Raspberry Pi cannot switch high-powered circuits like lamps or lights. These devices typically have 5v or 3v connections and have no other way to switch other circuits. Another use of relays is switching existing circuity in your house without changing too much: such as a sprinkler system. All the wiring is already run to a location for water sprinklers. Connect the existing power to the solenoid valve wires and use the relay and an Arduino to control your sprinklers. Very simple!
How Do I Use Relays with My IoT Project?
Let's say you want to control a desk lamp from the cloud. Well, first you need an Arduino or Raspberry Pi. Secondly, you need a relay, as we have discussed. Your first choice is to go out and buy all the individual components to make a reliable relay circuit. This choice is perfectly fine if you are interested in learning everything about a relay circuit. The second choice is to buy a pre-made PCB board with all the circuity and relays built on, including screw-down terminals for all connections. This method is the best method for prototyping with relays because nothing is permanent and it is a lower cost.
The Sainsmart 4-channel Relay Module is a small PCB board with four relays mounted on it with all the connections needed to control the relays. This board also includes an LED on it to display what relays are receiving power, essentially telling you which are switched "on."
Figure 4: The SainSmart 4-channel Relay Module
Figure 4 shows the SainSmart 4-channel Relay Module. Screw-down terminals at the top are where the power for the lamp will go. Figure 5 shows how the lamp circuit would work with this relay module. Hot power from the wall connects to the center screw down terminal. The "normally open" circuit then connects to the lamp. The circuit is completed with the lamp connecting to the neutral wall connection. The Arduino would be connected by using the header pins at the bottom right of the board.
Figure 5: Basic lamp circuit wiring diagram for the SainSmart 4-channel Relay Module
There are six header pins required to control all four relays on the board. In order from left to right they are: GND, IN1, IN2, IN3, IN4, and VCC. To control one of the relays, at least three of those connections are needed: GND, IN3, and VCC. GRN stands for ground; this will be connected to the Arduino ground. VCC is for Positive power connection; 5v connection from the Arduino. The IN3 would connect to the Arduino pin you are using to control the device from; for this example, it would be connected to pin 8 on the Arduino. When the Arduino code sets the pin to "HIGH," power will be applied and the relay module will "close" the circuit then turning on the lamp.
When working with high power levels, use extreme caution. Never work with wiring that is live; always work with disconnected or powered-down circuits. If needed, turn off the circuit breaker and lock out the panel to prevent someone from accidentally turning it back on.
Please be aware that there are solder points on the bottom of the relay modules that are in direct contact with the high power. You may have safely connected the power, but there are still connections that are not protected. With this in mind, do not work on metallic surfaces that may short circuit what you are working on.
Relays are simple devices that allow an easy way for logic-level power to control very high-powered devices. Adding some relays to items in your home can quickly automate an entire room full of lamps and lights and bring excitement to your Internet of Everything connected home!