Introduction: DIY Project to Build a Wi-Fi Controlled Extension Cord
SONOFF is designed by ITEAD to be put into an electrical switch or plug receptacle and is to be used with a home's electrical wiring.
A wi-fi enabled smart electrical outlet or light switch costs ~$45. SONOFF brings the cost down to about $7.
Smart outlets and switches can be controlled over the internet or by Echo.
I have never used the SONOFF.
Unleashing the full capabilities of the SONOFF requires reprogramming the device and connecting it up to a home automation system and to Echo. Installing the SONOFF in an electrical receptacle is also a lot of work
So, I wanted to build something easy, and then move on to more complex projects.
I thought an extension cord would be an easy project. It wasn't easy, but I learned a lot.
I am glad I started with an extension cord.
- This project could be dangerous. If you decide to do it, then you are responsible for any harm or damage you cause.
- This project will not work with an Android Phone. I tried. I could only get it to work with my wife's iPhone.
Step 1: Gather Parts
Get parts and tools (prices in USD):
- SONOFF basic from ITEAD $4.85
- 2 gang case 4x4x2 from Home Depot $1.83
- 4x4 cover from Home Depot $1.24
- 6 foot flat extension cord, 16/3 Home Depot $8.97
- 14 gauge butt splice Home Depot $2.39
Materials and tools I had:
- internet with Wi-Fi
- ~4 feet, 14 gauge solid AWG wire
- Two #4/40 bolts and nuts
- Electrical tape
- Box cutter
- Drill and metal drill bits
- Jig Saw and metal saw blades
Step 2: Background
In the U.S., most household outlets have three holes: large flat, small flat and D-shaped, and plugs have corresponding prongs.
- Large Flat = White Wire, Neutral, silver connector
- Small Flat = Black Wire, Live (aka Hot or Active)
- D shaped = Green or bare wire, Ground
US outlets deliver 110V to 120V at a peak of 15 or 20 amps, depending on the circuit breaker.
SONOFF only switches 1 of the 2 wires marked as either L or N.
It is critical to connect the wires correctly.
- L = Live
- N = Neutral
SONOFF must only switch the Live wire.
US outlets are 12-16 inches above the floor.
I have cut open a fair number of extension cords. Every cord I cut had stranded wire, rather than 12/14/16 gauge AWG solid. AWG solid wire is used in home wiring. Home wiring is bent a few times during installation, while extension cords are subject to constant bending. Thick solid AWG wire tends to break after many bends and is not suitable for an extension cord.
My home has multiple Wi-Fi Acess Points (AP): 802.11b/g, 802.11n or 802.11ac. Each AP broadcasts a different SSID. Newer computing and TV devices use 802.11ac. Older ones use 802.11n. I am using 802.11b/g for the SONOFF. My 802.11n and 802.11ac SSIDs are longer than 10 characters.
For SONOFF to work, the SSID it connects to must be less than 10 characters.
Smartphones (Android and iPhone) have an option that allows automatic switching between Wi-Fi networks and between Wi-Fi and LTE to get the best throughput. This feature must be disabled.
Step 3: Make a Case for the SONOFF
Most US extension cords use stranded wire, and the SONOFF takes solid wire.
The SONOFF comes with two "strain reliefs" and four posts for the wire. However, the strain reliefs and posts are not designed for stranded wire. Stranded wire easily pulls out of the SONOFF. A slight tug on the wire and it will pop right out. The wire that comes out could be live and is very dangerous.
So, for an extension cord, the SONOFF needs to be put in a case.
I selected a 4x4x2 electrical box for the case.
- Use jigsaw with metal bit and slowly cut off the case's wings
- Drill two 5/16 holes in the side of the box for the extension cord
- Since the SONOFF will be in a case, I am not using the white plastic end pieces of the SONOFF
- Determine location of SONOFF within box and mark and slowly drill 2 holes using a metal bit that is the same size as the holes in the SONOFF base
- Use #4-40 bolts and nuts to attach SONOFF to the case bottom
I could not see the SONOFF LED through the SONOFF's case, so I drilled a hole in the SONOFF case over the LED (see image with arrow).
Step 4: Prepare the Extension Cord
Get a 6ft long white extension cord, with:
- A 3 prong plug
- One or more 3 prong outlets
- A flat ribbon wire between the plug and the outlet(s), which makes it easier to identify each of the three wires
- Home Depot has extension cords with two prongs and two prong outlets (16/2)
- Be sure to get the one with both a 3 prong plug and 3 prong outlets (16/3)
Cut the plug end of the extension cord about 20 inches long. About four inches will be lost. When plugged into a household socket, the case should sit flat on the ground.
Using a box cutter make two 4 inch cuts parallel with the cord so as to separate the three wires. On my extension cord, the middle wire was green and had an inner plastic sheath. Do not strip or cut into the outer wires.
Mark the extension cord showing Live, Neutral and Ground
- The extension cord's plug did not have a prong with a large flat end, so I determined Live (small end) by the orientation of the plug with the outlet.
- The extension cord's outlet(s) did have a large flat end.
- If yours doesn't, use the orientation of the plug with the outlets to determine the live outlet (small end)
- Use a multimeter set to Rx10 to identify each wire in the extension cord and its corresponding prong or plug.
- Using an indelible marker, I marked the wires near the plug and outlets, as follows:
- Black is for Live
- White is Neutral
- Green is ground
Push the cut ends of the extension cord with the plug into the case through one of the 5/16 inch holes on the Input side of the SONOFF
Push the cut ends of the extension cord with the outlet(s) into the other 5/16 hole in the case on the Output side of the SONOFF
The extension cord requires strain relief. A simple way to create strain relief is to tie the Live and Neutral wires in the extension cord into a slip knot inside the case.
Step 5: Create Connecting Wires and Wire It Up
The stranded wires of the extension cord must be transformed into solid wires required as input to the SONOFF
Get 14 gauge solid AWG wire (I used invisible dog fence wire from local hardware store, which is sold by the foot)
- Cut four pieces 6 inches long
- Strip one end of each wire at 1/2 inch - this goes into the butt splice
- Strip the other end of each wire at 1/4 inch - this goes into the SONOFF
Bend the four wires so they can go into the SONOFF and not interfere with one another.
For the following steps, ensure Live goes to Live and Neutral to Neutral, and the plug end of the extension cord goes into the Input side of the SONOFF, and the outlet of the extension cord is connected to the output of the SONOFF.
For each pair of wires, insert a stranded wire and a solid wire into a 14 AWG butt splice. Use a crimping tool to lock the stranded and solid wires in place.
Insert the correct wire into the correct hole in the SONOFF and tighten the screw.
If you are certain everything is wired together correctly, then plug the extension cord into an outlet.
The SONOFF should blink.
Step 6: Setup the SONOFF With E-WeLINK App
Use an iPhone (I could not get the Android version to work)
- Get the EWeLINK app from the Apple Store
- On your smartphone, switch off mobile data and switch off smart switch
- To shut off smart switching and LTE on the iPhone: Settings, Cellular, turn off Cellular Data
- Prior to doing the above step and after the SONOFF device was discovered, I would get error messages like:
- "device offline" and "failed to switch to device wifi"
SONOFF and smartphone must use the same 802.11 AP. Normally, our phones connect to 802.11ac and cannot connect to my 802.11n or 802.11b/g APs.
Start the EWeLINK app and follow the directions. I had to do this a couple of times to get it to work.
If everything works, then put the lid on the blue extension cord case.
The video shows the light switching on and off from an iPhone.
Step 7: References
Step 8: Appendix: Troubleshooting
SONOFF "device offline"
Problem Description: SONOFF first generation can connect, pair, register and so on, but the SONOFF remains offline.
ITEAD User's Guide says:
"1.1. Green led quickly blinks one time and repeats, which means device failed to connect to router. The reason may be you have entered wrong WiFi password or your device is too far away from router, which causes a weak WiFi signal. The device can not be added to the 5G-wifi-router,only the 2.4G-wifi is OK. At last, make sure that your router is MAC-open."
Android ewelink app does not work. Use iPhone ewelink app
Use an AP with a 10 character or less SSID.
Determine if SONOFF first generation works with n-only AP, or if it only works with b/g.