Configure your SMART-OUTLET

Smart Outlet using an ESP866



Others also bought...


DIY Smart Oulet Using an ESP8266-RELAY, Project Box, & Supplies (Assembly required)


We wanted to develop a DIY Smart Outlet that was simple to build and low cost.  Here at the Circuit Specialists storefront, we have a series of equipment displays that we leave on all the time, day and night. This obviously is not ideal, as it drains power and shortens the life of the equipment, so we decided to do something about it.  We also thought our customers might want to build one too so we documented the build. We designed and built a custom device which can wirelessly control the flow of electricity to the devices via a relay, either manually or on a set schedule.


Initial Design

We started with the design of the contraption. The ESP8266 seemed like a perfect choice for the project, as it was simple, low cost, wifi supported, and small enough to fit into our project box.  They also make relays and relay shields that are compatible with it as well, which means it would be very easy to control the flow of power to our outlet. We made a small prototyping sketch just to get the general layout and idea of the Smart Outlet onto paper.




A relay is what we will use to control the flow of power to the outlet. The relay works by opening and closing a gate to connect or disconnect a power connection, almost like a switch or toggle button does. 

For example, above is a picture of a simple relay circuit. The COM connection on the relay is the part that actually changes connection. In one state it’s connected to NO, and the other NC when it is powered. NC stands for Normally Closed, while NO stands for Normally Open. If we connect in series a powerline with the COM port, and wire to the NO port as pictured, then the circuit will be completed when the relay is turned on. This is what we want, so we’ll wire our outlet as pictured in the diagram. In our case, the relay is controlled by the ESP8266, which means we can program the relay to open and close at specific times or under certain conditions, which is perfect for making a smart outlet controlled by a specific schedule.



We used two receptacles to power the device. We used a simple IEC input for our power, which is used to power a variety of devices such as monitors and computers, and then we chose a simple universal outlet for the output. This allows us to plug in our display devices like any other outlet, and making it much easier to repurpose in the future if needed.


For the AC/DC converter, we didn’t know what to use at first. There aren’t many off-the-shelf solutions for an inexpensive converter, so we had to get creative. We tore open a simple USB wall adapter, which converts the AC signal from the wall to a DC USB port. We simply desoldered the USB ports and the wall connector, labeled the AC and DC sides respectively, and soldered wires to the adaptor. This allowed us to power the ESP8266 directly inside the box with the AC input from the power input port.




The wiring of the box is very simple. The power comes in from the IEC cable through 3 prongs - live, neutral and ground. This is AC power obviously, since it is coming straight from the wall. We connect the ground and neutral wires straight to the output receptacle, this will not complete the circuit by itself. We then connect the live wire into the COM port on the relay - this is what will switch on and off to complete our circuit and power our outlet port - and then connect the NO side to the live prong of the output port with a small piece of wire. Back to the power input, we also have 2 small wires running off the live and neutral prongs going to the AC/DC converter. We then have 2 small wires running off of the DC side of the converter. The red wire goes to the power switch on the input IEC outlet, which is to easily reset the ESP8266 and turn on/off the box when not in use. You don’t have to wire in the switch at all if it’s too complicated, but we did it to make the box easier to use. After that, we connect the red and black wire to the +- ports on the relay board to power it.

It’s very important when you're dealing with this much voltage that you’re using the correct gauge of wire. We’re using the small 16 gauge wire ONLY for the small current DC that we’re using to power the ESP8266. For the actual wall power, you want to use something thicker, or you risk the wire melting or worse. For this project, we wanted to keep the budget low, so we simply cut open an IEC power cable to harvest the wire, but you can use any wire you can find that’s 14 gauge or bigger. Don’t risk using thinner cables for your safety.


Cutting the Box

We recommend using a dremel tool or similar rotary cutting device in order to make the needed cuts to the project box.  There is a good tutorial here on how to cut a plastic project box

Powering On

The first time we powered on the box, we accidently blew up an AC/DC converter because we had it wired backwards. Make sure that when you are taking apart the USB power brick that you pay attention to the polarity, and follow our pictures for an easier time. Once we had it powered on, an LED on the 8266 lights up red to tell us it’s on. The web server takes about 10 seconds to boot, which you can then connect to the access point and setup your wifi credentials at the address

Once you do this, you must sign into your router and check the IP address of the box, which should be under ESP8266 or something similar.

You could also reprogram the ESP8266 to set the variable named "consoleOutput" to "True" in the file and then connect the ESP8266 to a UART adaptor and connect to it with PUTTY to see the IP address it was assigned. See the "Code" section.

Once you have the assigned local IP address, simply put it into your browser to open the interface and start changing your settings.


List of Materials

ESP8266-RELAY Relay board controlled by an ESP8266 from Espressif

23-513 Power Cord x 2 - stripped one for high gauge wires to make internal connections, used the other one to actually power the box

PB-4P Plastic Project Box

66-5000 Input Receptacle

SOCKET-PLUG universal NEMA15 plug socket Output Receptacle

USB-WALL Makeshift AC -> DC Converter


Suggested Tools & Supplies

Soldering Iron


Rotary Cutting Tool

Heat Shrink Tubing






Mitch Zakocs: Project Lead, Circuit Design, Programming, Videos, Photos, Writing

Jake Pring: nanoWebSrv python library

All photos taken on an iPhone 8+