DIY WiFi Outlet (HariFun#135)

by HariFun in Circuits > Arduino

48430 Views, 568 Favorites, 0 Comments

DIY WiFi Outlet (HariFun#135)

573d3bba2e7fb6867800107a.jpeg
HariFun #135.1 - DIY WiFi Outlet

In this instructable, I will take you along on my journey of building this WiFi Outlet.

Parts

20160415_222103-parts.jpg

The final box will contain:

  • ESP8266 (any version will do)
  • 5V Relay Module
  • AMS1117 Low Drop Out Regulator
  • 1K Resistor
  • Duplex Outlet
  • Wall Box
  • Wall Plate
  • Cellphone Charger (5V output)
  • Power Cord

Only needed while programming the ESP8266:

  • FTDI Usb to Serial Converter (3.3V version)
  • Some jumper wires

WARNING!!!

Screen Shot 2016-05-14 at May 14 - 9.48.41 PM.png
20160407_203226.jpg

High voltage definitely would hurt you and potentially could kill you! So please be careful. If you don't know what precautions to take, please find someone who does. You've been warned.

Edit: fellow instructable brought up a good point. Thanks Spark Master!
"I would mention you will probably void any Home Owners Insurance you have if you do this in NYC. Ask the electrical inspectors listed in the phone book for your area."

Charger Surgery

20160510_220503_001.jpg
20160510_233924.jpg
20160408_200843.jpg
20160408_200902.jpg
20160510_234240.jpg
20160511_005000.jpg
20160511_005248.jpg
20160511_005352.jpg

I considered just soldering wires to the mains input and use a USB cable for the output. However, in the end I decided to keep all the high voltage inside the charger. A gentle pry with a box cutter popped it open.

I replaced the input wire with a slightly longer wire.

I also removed the USB connector because plugging in a USB cable would have taken more room.

I then put everything back into its original container.

High Voltage Wiring

00-strip-cable-20160416_192648.jpg
02-Feed-cable-20160416_193019.jpg
tab1.jpg
tab2.jpg

I recycled a computer power cable for this project.
Obviously, we want the relay to switch the live wire instead of the neutral.

I opted to break one of the tabs that joins the two outlets. This allowed me to wire up one of the outlets to be always on, while the other outlet is switched by the relay.

ESP8266 & Relay Wiring

20160526_190139.jpg
top.jpg
under.jpg

The wiring is fairly simple, so I opted to solder everything right around the ESP8266 instead of creating a custom PCB.

You could pretty much use any ESP model. I ended up using an ESP12.

The pushbutton switches and USB to Serial module are only necessary to program the ESP. That's the reason for the "header pins" on the ESP:

  • Ground
  • RX
  • TX
  • GPIO0 (bring to ground at power up to put ESP in program mode)
  • Reset (optional)

As you can see in the photos, instead of mounting the relay module on a PCB, I use the relay module as the center piece. I mounted the AMS1117 LDO (Low Drop Out voltage regulator) and the ESP8266 around the relay module. The wires are stiff enough to hold the ESP in place. I discovered that the 3.3V output of the LDO is available at the middle pin AND at the heatsink which is more convenient structurally to hold the ESP in place.

Programming

Screen Shot 2016-05-18 at May 18 - 8.16.02 PM.png
Screen Shot 2016-05-18 at May 18 - 8.34.37 PM.png
Screen Shot 2016-05-18 at May 18 - 8.34.46 PM.png

When it comes to software, there are many options. The simplest one I found at the writing of this Instructable is Blynk. Download the free app onto your iPhone or Android. Register and get the AuthToken.

In the Arduino IDE, open Library Manager (Sketch > Include Libray > Manage LIbraries...) to install blynk library.

Under File > Examples > Blynk > BoardsAndShields > ESP8266_StandAlone

Modify the sketch to include your AuthToken, home WiFi SSID and password.

Hold GPIO0 to ground (using a switch of just temporarily wire it to ground) while powering it up or pressing reset.

Once the upload is done, you no longer need the USB to Serial module.

Setup the button in the Blynk app and you're done!

Have fun!