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.

PCBWay Ad

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:

Arduino Controlled Power Outlet Basic Diagram

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
Build an Arduino Controlled Power Outlet - All of the Necessary Parts

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:

Build an Arduino Controlled Power Outlet - Cutting the Electrical Cord

Remove one of the knock out plugs from the electric outlet box:

Build an Arduino Controlled Power Outlet - Knock Out Plug Removed

Install the NM/SE Connector:

JLPCB Ad

Build an Arduino Controlled Power Outlet - Installing the NM/SE Connector Outside of Box
Build an Arduino Controlled Power Outlet - Installing 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:

Build an Arduino Controlled Power Outlet - Bringing the Electrical Cord Into the Outlet Box

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:

Build an Arduino Controlled Power Outlet - Attaching the Short Hot Wire to the 5V Relay

Connect the signal, Vcc, and ground wires to the relay:

Build an Arduino Controlled Power Outlet - Attaching the Signal, 5V, and Ground Wires to the 5V 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:

Build an Arduino Controlled Power Outlet - Stripping the Hot, Neutral, and Ground Wires

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:

Build an Arduino Controlled Power Outlet - Wiring the 5V Relay to the Hot Wire

Connecting the Hot, Neutral, and Basis Wires to the Electrical Outlet

Build an Arduino Controlled Power Outlet - Before Wiring 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:

Build an Arduino Controlled Power Outlet - View of the Hot Terminal Screw

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:

Build an Arduino Controlled Power Outlet - View of the Neutral Terminal Screw

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:

Build an Arduino Controlled Power Outlet - View of the Ground Terminal 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:

Build an Arduino Controlled Power Outlet - Inserting the 5V Relay into the Electrical Outlet Box

Now connect the ground wire to the footing terminal of the outlet:

Build an Arduino Controlled Power Outlet - Attaching the Ground Wire

Connect the neutral wire to the neutral last of the outlet:

Build an Arduino Controlled Power Outlet - Attaching the Neutral Electrical Wire

Connect the hot wire from the relay to the hot terminal of the outlet:

Build an Arduino Controlled Power Outlet - Attaching the Hot Electrical Wire

Now that all of the electrical connections have been made nosotros can screw the outlet into place in the electrical outlet box:

Build an Arduino Controlled Power Outlet - Without Electrical Box Cover Plate

Attach the electrical box cover plate:

Build an Arduino Controlled Power Outlet - The Completed Electrical Outlet Box Top View

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:

Build an Arduino Controlled Power Outlet - The Completed Electrical Outlet Box Data, 5V and Ground Wires
Build an Arduino Controlled Power Outlet - The Completed Electrical Outlet Box

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:

Arduino Controlled Power Outlet With DHT11 Humidity and Temperature Sensor Control
Build an Arduino Controlled Power Outlet - DHT11 Humidity and Temperature Sensor Controlling a Light Bulb

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 .

Build an Arduino Controlled Power Outlet - DHT11 Humidity and Temperature Sensor Controlling a Light Bulb

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!

deasoncaushre.blogspot.com

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

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel