Archive for March, 2017

Completely mandatory Eagle accessories

March 17, 2017

This one is just me showing off.  All my life my dad has had a brass embellished american flag and eagle licence plate frame in the basement on a workbench.  Last year he picked up some model paints and touched it up, then surprised me by installing it on my 1957 Chevy 210 for me when I got home from work. I really like it and decided that I would like another one for my new AMC eagle.  It turns out that it’s made by a company called Baron LFI and originally came with a keychain, moneyclip, and pin.  He found me a new one on Amazon, but it just looks too shiny, almost cheap in the pictures.  Maybe I’ve been conditioned to think that new products are photographed like that and my experience has shown me most new products are crap.  I really gravitate toward the items on ebay that have one photograph taken of them that shows how they really look (I try not to buy things with stock photos).  I found one on ebay proclaiming to be from 1985 and compared them.  The older one has different slots at the top to bolt the plate to, that sealed it, I bought the old one.  I didn’t care about the slots  specifically, but that told me it wasn’t the same mold and therefore could be worse in ways I couldn’t see.  I think it looks pretty good and installing it reminded me I need to sandblast and paint that spring-loaded frame.

Lookin’ good.

The home page for this project is here, it has a link to the album of pictures.

Eco Plug (ESP8266) hack, finally!

March 16, 2017

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.

1 GND
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
12 DVDD / GPIO5
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 {
CUSTOM_OUTLET,
SONOFF_BASIC,
SONOFF_RF,
SONOFF_SV,
SONOFF_TH,
SONOFF_DUAL,
SONOFF_POW,
SONOFF_4CH,
S20,
SLAMPHER,
SONOFF_TOUCH,
SONOFF_LED,
CH1,
CH4,
MOTOR,
ELECTRODRAGON,
EXS_RELAY,
WION,
WEMOS,
MAXMODULE };

/********************************************************************************************/

#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.