Turn a Cheap WiFi Plug Into an OpenHAB ESP8266 Switchable Plug




Introduction: Turn a Cheap WiFi Plug Into an OpenHAB ESP8266 Switchable Plug

These things out of the box are cheap and insecure. These plugs use no encryption and connects to servers openly over the web. To make things worse, each device is usually authenticated and identified using a standard serial or MAC address. Basically, any user should be able to use anyone else's switch with a little guess work.

Next: Thank you!

  • Thank you to The Great Geekery for doing the research and discovering the pinout
  • Thank you to the writers of ESP Easy and their work for a solid DIY IOT using ESP8266



High voltage may cause severe personal injury or death disconnect all power supplies before opening the electrical enclosure or servicing.

Step 1: Wire It Up

Solder the esp, on the plug, to the header as shown in the pictures. I bridged the ground to an extra pin on the header so that I could isolate the GPIO 0. You will need to ground the GPIO 0 in order to program the esp chip. Remove the ground in order to test and read the serial log using Putty or similar.

Step 2: Change the Firmware the Plug With ESP Easy

Download ESP Easy (Current version is 120 at the time of this Instructable)

ESP Easy firmware Mainpage for ESP Easy is here in case link is broken.

Unzip the contents. I recommenced using c:\Esp8266

Edit the flash.cmd file to direct the script to your current directory. (line 7 in code below)

@echo off
set /p comport= Comport (example 3, 4, ..) : set /p fsize= Flash Size (example 512, 1024, 4096) : set /p build= Build (example 71, 72, ..) : echo Using com port: %comport% echo Using bin file: ESPEasy_R%build%_%fsize%.bin C:\Esp8266\esptool.exe -vv -cd nodemcu -cb 115200 -cp COM%comport% -ca 0x00000 -cf ESPEasy_R%build%_%fsize%.bin pause

Plug the USB serial adapter into your newly wired header. Make that the VCC and GRN match. Once pluged your PC will assign the adapter a port. Make note of this port for the flashing procedure. Port 5 in my case.

Double click the Flash.cmd file to start the flashing procedure. Type in:

  • your port number (5 in my case)
  • Flash Size: 512
  • Build: 120 (as of the date of this post)

If all goes well, the serial adapter and ESP will start to blink as the firmware is being flashed to the ESP.

That's it, ESP Easy is on this plug now. Button it up and plug it into the wall to setup. I ended up removing the push button to make room for the header. I think that I'll wire it up much tighter on the next one.

Step 3: Setup ESP Easy and OpenHab

Follow the Easy Setup Wizard instructions to get your ESP connected to your network.

I've included a shot of my setup that goes with my previous tutorials.

RECOMMENDATION! Change the "WPA AP Mode Key" to a complex password. If you don't and your ESP looses connectivity to your network, it will create the default network and open up to anyone within range. I pull my random passwords from GRC's Ultra High Security Password Generator.

Here is my OpenHAB code:

Sitemap (I placed this switch into a "Quick Access" Group)

Frame label="Most Used" {<br>        Group    item=Quick_Access label="Quick Access" icon="quick_access"
        Group    item=Masters    label="Master Switches"    icon="MasterSwitch"    
        Group    item=Weather label="Weather" icon="weather"        
        Group    item=Test label="Test" icon="TestIcon"


Switch	WrkChc_Portable_Plug01	"Play Room Laser Light"	(All,Quick_Access)        {mqtt=">[mymosquitto:/WrkChc01/gpio/15:command:ON:1],>[mymosquitto:/WrkChc01/gpio/15:command:OFF:0]"}<br>

As you can see the ESP Name matched the mymosquitto protocol and we are using GPIO 15 for the relay.

Enjoy a secure switch!

Be the First to Share


    • Home and Garden Contest

      Home and Garden Contest
    • Electronics Contest

      Electronics Contest
    • Chocolate Challenge

      Chocolate Challenge



    4 years ago

    I also worked with a WorkChoice 1 Ol Wi-Fi Indoor Switch that looks the same inside as your pictures. To program it with an augmented Arduino IDE, I also had to ground CHIP_EN pin (the one below VCC) besides grounding GPIO0. A large capacitor across ESP8266 VCC & GND pins also helped. I had trouble soldering to the pads so I made a programming jig. See this site for the writeup:



    5 years ago

    I followed your instructions to the letter for a ECO Wifi Plug it flashed when loading the ESPEasy and the blue LED flashed as well. I put it all back together and plugged it in but there were no lights or nothing showing on the plug. I followed the wizard instructions but it could not find the AP of ESP_0 or anything close to that. What could I have done wrong? The model plug I used is just like the one the Great Geekery had on his site. Any help would be great. Thanks


    Reply 5 years ago

    Make sure that the GPIO0 is not grounded. The ESP could be booting in flash mode if it is.


    Reply 5 years ago

    Once the flash was done I pulled the jumper off before closing it all back up. Now I noticed on Geekery's site that he did not put a connection on the GPIO0 on the ECO plug model would that make a difference?


    Reply 5 years ago

    not sure. I doubt it. Is the led coming on when powered? Is it blinking? Or steady?


    Reply 5 years ago

    The LED of the ESP is glowing red (steady) and then blinks (plus another one on board (red) and one on plug (blue)) when you install flash. Now I could not fit the wires and header in the device so DE-soldered them off. It was easy to put on so if I needed to update no big deal.