Eco Plug (ESP8266) hack, finally!

This has been a very long time coming. I first heard about these outlets more than a year ago via reddit and was intrigued.  This is a very convenient form factor for an ESP, a power supply for it, and a relay to control something via mains.  This was before the prevelance of the sonoff (wiki) or electrodragon (wiki) modules that are now so cheap and with some digging I found out that these ‘generic’ modules that were being carried by Home Depot, Walmart, or wherever you don’t expect to buy ESP modules had power monitoring in them.  The actual manufacturer of these parts is KAB Enterprise Co., Ltd and through their website you can see all the different modules they make and some names that will help you google for sellers of them (even a wifi in-wall switch).  All of the wifi devices are basically an ESP with some other circuitry that you may have to reverse engineer or bypass (like I did).  You can find these at Walmart (or probably just their online store).  There are some deal sites that have found these for very cheap prices but even then you may want to just buy the sonoff POW to be sure you have power monitoring with no major modifications.

Chip to be bypassed still present, module removed

module back side (I toasted it)

Reset switch unpopulated (I added one and drilled a hole) and chip to be bypassed remoced

As the KAB website shows there is a difference between the CT-065W and the CT-065W (Advanced) in that only the advanced one has power monitoring capability.  This is apparent if you look at the other reddit thread and have people with modules that have additional components on them.  It was discovered that the power monitoring IC is the hlw8012 that was not terribly well known (to me) until the POW came out.  The extra hoop the CT-065W (Advanced) modules have is that they have an extra chip in there, labeled on the underside (discovered by the person who always saves my ass), called the 1588NAZ04 and there has been some efforts to reverse engineer it in the comments section here.  I took the pinout from here and tweaked it for how I modified my plugs, it is the same pin numbering as here.

2 Power 3v3
3 CHIP_EN reset sw
4 XPD_DCDC / GPIO16 PF HLW8012 CF power
5 MTMS / GPIO14 VS GPIO05 HLW8012 Sel output
6 MTD1 / GPIO12 VC HLW8012 CF1 voltage / current
7 MTCK / GPIO13 power sw
8 MTD0 / GPIO15 Y to main board , D8 (power)
9 GPIO2 D3 (wifi)

10 GPIO0
11 GPIO4
13 U0RXD
14 U0TXD
15 RST
16 GND
17 TOUT / No Connection?
18 GND

I decided that for my modules I was going to just outright remove the chip and use some of the many extra pins on the ESP module to talk to it (indicated in red above), this basically converts it into a POW with a different mapping.  My main motivation is because I have come to really like this firmware, partially because other people already use it and it’s very easy to configure.  With my use of these modules for OpenHAB I really needed these modules to be stable and flexible.  There are other firmwares that people have used on this device (or family of devices, really) but I have my favorite.

Flashing harness, I had to add an esp-12 because I toasted the original, this is not an upgrade, just a repair by me (look closely and you can see that I wired to the pads of the chip I removed)

For flashing these modules I used this other firmware‘s tutorial which worked flawlessly.  The modifications I made to the firmware to add my own hacked outlet module definition was quite easy, it just involved extending a couple tables in the sonoff_template.h file and giving my variant a list of pins and their uses.  I have included that section here:


// Supported hardware modules
enum module_t {


#define MAX_GPIO_PIN 17 // Number of supported GPIO

typedef struct MYIO {
uint8_t io[MAX_GPIO_PIN];
} myio;

typedef struct MYTMPLT {
char name[16];
myio gp;
} mytmplt;

// Default module settings
const mytmplt modules[MAXMODULE] PROGMEM = {
{ “Custom Outlet”, // modified eco outlet (ESP8266)
GPIO_USER, // GPIO00 Optional sensor
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
GPIO_LED1_INV, // GPIO02 Blue Led (0 = On, 1 = Off)
GPIO_USER, // GPIO03 Serial TXD and Optional sensor
GPIO_USER, // GPIO04 Optional sensor
GPIO_USER, // GPIO05 Optional sensor
0, // GPIO06 (SD_CLK Flash)
0, // GPIO07 (SD_DATA0 Flash QIO/DIO/DOUT)
0, // GPIO08 (SD_DATA1 Flash QIO/DIO)
0, // GPIO09 (SD_DATA2 Flash QIO)
0, // GPIO10 (SD_DATA3 Flash QIO)
0, // GPIO11 (SD_CMD Flash)
GPIO_HLW_CF1, // GPIO12 HLW8012 CF1 voltage / current
GPIO_KEY1, // GPIO13 Button
GPIO_HLW_SEL, // GPIO14 HLW8012 Sel output
GPIO_REL1, // GPIO15 Red Led and Relay (0 = Off, 1 = On)
GPIO_HLW_CF, // GPIO16 HLW8012 CF power
{ “Sonoff Basic”, // Sonoff Basic (ESP8266)
GPIO_KEY1, // GPIO00 Button
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
0, // GPIO02
GPIO_USER, // GPIO03 Serial TXD and Optional sensor
GPIO_USER, // GPIO04 Optional sensor
0, // GPIO05

For right now that’s it.  The configuration for this firmware is deep and takes some looking but I feel like I could implement any sensor I want in their framework with a small effort.

The rest of this series can be gotten through from the home page here.






2 Responses to “Eco Plug (ESP8266) hack, finally!”

  1. Intro to my ESP8266 adventures | Evan's Techie-Blog Says:

    […] Power node (integrates current reading and relay like the Ubiquiti stuff) […]

  2. Brent Anderson Says:

    Thanks for your work on re-flashing an EcoPlug. After I bought some WorkChoice WiFI Outlets from Walmart recently, I experienced
    difficulties with re-programming the currently available ECOPlug version of ESP8266. I had trouble making the wiring connections & with getting an upload to work. The current version is constructed differently from what is previously pictured & seems to enter flash mode somewhat differently. From my experience, successful uploading needs one more connection on the ECOPlug’s ESP8266 board. Adding a large capacitor can help. I also worked out a programming jig to avoid the difficult soldering to the board’s pads & to avoid cramming wires into a crowded case. See this thread for documentation >

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: