Device Plus Ranjit Mohanty Content Uploads 2016 Arduino Basics
Ane of the most useful things you tin can do with an Arduino is use it to control higher voltage electronic devices. Any device yous normally plug into a wall outlet tin exist activated by a sensor or controlled in other ways with the Arduino. The possibilities are countless considering the variety of sensors and modules available to us today.
In this tutorial, we'll be using a 5V relay to switch the current to a power outlet on and off. We'll use the Arduino and a sensor to command when the relay switches. To learn more about the 5V relay and information technology'south different modes of operation, see our article "How to Gear up a 5V Relay on the Arduino".
We could e'er wire the relay directly to the device nosotros desire to command, simply information technology'due south more practical to get one step closer to the source and switch the ability at the outlet. That way you can utilize it for multiple devices without having to re-wire the relay or cut into the device'south power supply. In this project, we'll connect a power outlet box to a grounded extension cord and install a 5V relay inside the box so we tin can control it with the Arduino.
Building the Arduino Controlled Power Outlet
WARNING!! – THIS PROJECT INVOLVES WORKING WITH High VOLTAGES THAT CAN Crusade SERIOUS INJURY, Death, AND/OR SET YOUR HOUSE ON Fire. Please PROCEED WITH CAUTION, AND Ever MAKE Certain CIRCUITS ARE UN-PLUGGED Before WORKING ON THEM.
We will install the 5V relay in-line with the positive (hot) wire of the 120-240V power outlet in the normally open configuration. The negative (neutral) wire and the ground wire will exist connected straight from the power cord to the outlet. The 5V relay will plow on the current to the outlet whenever it receives a 5V bespeak from the Arduino.
Here's a diagram that outlines the connections:
Assemble the Parts
The parts I used are listed beneath, but you tin can use other types. This is just what I found at my local Domicile Depot. I've included links to these parts on Amazon so you can go an thought of what they toll, but I got everything (except the Arduino) for under $22.00 USD.
- Arduino UNO R3
- SRD-05VDC-SL-C 5V Relay
- Electrical Outlet Box
- Electrical Outlet
- Electrical Outlet Box Cover Plate
- three/8″ NM/SE Connector
- Ability Strip
- Signal, Vcc, and Basis Wires
Constructing the Box
Cutting the cord on the power strip and make up one's mind which wire connects to each prong on the plug with a homemade continuity tester. My cord has 3 wires. The neutral (white) wire is connected to the larger prong, the hot (black) wire is connected to the smaller prong, and the basis (green) wire is connected to the round prong:
Remove one of the knock out plugs from the electric outlet box:
Install the NM/SE Connector:
Remove near three to iv inches of the outer plastic sheathing from the electrical cord, then feed information technology into the box through the NM/SE connector:
Wiring the Relay
Cutting a iv inch slice of the hot wire and strip off about 1/4 inch of the insulation. Insert it into the NO last of the relay and tighten the screw on the relay terminal to brand a secure connection. Now is a proficient time to strip the other end of this wire and then we can connect it to the electrical outlet later:
Connect the signal, Vcc, and ground wires to the relay:
Strip the neutral and basis wires on the electric string so they have near three/4 inch of exposed copper. We'll connect these to the power outlet later. The hot wire but needs about ane/4 inch since it will exist inserted into the C last of the relay:
Insert the hot wire from the electrical string into the mutual (C) terminal of the relay. Double check that both terminals of the relay are securely screwed down:
Connecting the Hot, Neutral, and Basis Wires to the Electrical Outlet
The right side of the power outlet with the smaller slot is the hot side of the outlet. The hot (blackness) wire from the NO concluding of the relay will be screwed to the hot terminal with 1 of the golden colored screws:
The left side of the outlet with the larger slot is the neutral side. The neutral (white) wire from the power cord will be screwed to the neutral terminal with i of the silver colored screws:
The D shaped slots are for the basis prong. The footing (dark-green) wire from the ability cord will be screwed to the ground terminal with the green screw:
Earlier connecting the wires to the outlet, position the relay and all of the wires inside the box to make sure information technology fits well. Now is a good time to trim the wires and tighten the screws on the NM/SE connector:
Now connect the ground wire to the footing terminal of the outlet:
Connect the neutral wire to the neutral last of the outlet:
Connect the hot wire from the relay to the hot terminal of the outlet:
Now that all of the electrical connections have been made nosotros can screw the outlet into place in the electrical outlet box:
Attach the electrical box cover plate:
And we're done. Now nosotros take a 120V electrical outlet that can be controlled by an Arduino. Everything looks make clean, and the relay command wires are ready for a breadboard:
Testing information technology Out
Allow's examination out the Arduino controlled ability outlet by programming a light fixture to turn off when the humidity gets above a certain bespeak. To make this excursion y'all'll need a DHT11 humidity and temperature sensor.
Connecting the Arduino
Follow this diagram to make the connections:
Programming the Arduino
After making all of the connections, we're gear up to program the Arduino. Upload this program to the board to control the outlet with the DHT11:
#include <dht.h> dht DHT; #define DHT11_PIN 7 int pinOut = 8; void setup(){ Serial.begin(9600); pinMode(8, OUTPUT); } void loop() { int chk = DHT.read11(DHT11_PIN); Serial.print("Temperature = "); Serial.println(DHT.temperature); Series.print("Humidity = "); Series.println(DHT.humidity); if (DHT.humidity <= twoscore){ digitalWrite(pinOut, HIGH); } else { digitalWrite(pinOut, Depression); } delay(500); } This program takes the humidity data output by the DHT11 and tells the Arduino to output a HIGH signal at pin eight until the humidity reaches 40% or greater. Therefore, the light seedling will exist on below forty% relative humidity. If the humidity goes above 40%, the programme tells the Arduino to output a Low indicate at pivot 8, and the light seedling volition be switched off.
You can change the humidity at which the relay turns on and off in line 20, where it says if (DHT.humidity <= 40){ . You tin as well use the temperature data instead of the humidity (or utilize both) by changing DHT.humidity to DHT.temperature .
Thanks for reading! This has probably been one of the most useful things I've built so far. Yous should definitely build 1 for yourself, especially if you're interested in controlling devices around your home. Let me know in the comments if you take whatsoever questions almost this project, and be sure to share it if y'all know someone else that might enjoy information technology as well!
Source: https://www.circuitbasics.com/build-an-arduino-controlled-power-outlet/
0 Response to "Device Plus Ranjit Mohanty Content Uploads 2016 Arduino Basics"
Postar um comentário