Introduction: ESP8266 EcoPlug Wifi Smart Outlet MQTT Mod for Less Than $15

Picture of ESP8266 EcoPlug Wifi Smart Outlet MQTT Mod for Less Than $15

Thanks to Scott for figuring out the pinout on these cheap Wifi Outlets.

Pinout/Guide Available Here

This guide will show you how to put Homie 2.0 (still in beta) on your brand new Ecoplug and use OpenHAB or any other MQTT device to control it vs using their app.

The original firmware on these things also phones back to a server in China.

Items Needed.

Step 1: Pinouts/Opening

Picture of Pinouts/Opening

This is a nice little compact wifi controllable plug that can be done in other 10 minutes.

Solder the jump cables in the Pins

  • Ecoplug VCC to 3.3V on FT232
  • Ecoplug GND to GND on FT232
  • Ecoplug TX to RX on FT232
  • Ecoplug RX to TX on FT232
  • Ecoplug GPIO0 to GND on FT232

Since I'm using Homie MQTT Framework for this project.

Download Homie from their Github Follow the read me on how to properly flash a configuration file from their readme.

Arduino Sketch

#include <Homie.h>

#define FW_NAME "ecoplug" #define FW_VERSION "1.0.2"

const int PIN_LED = 15; const int PIN_BUTTON = 13;

int buttonOLD=LOW;

HomieNode light("light", "light");

bool lightOnHandler(HomieRange range, String message) { if (message == "true") { digitalWrite(PIN_LED, HIGH); Homie.setNodeProperty(light, "on").send("true"); Serial.println("Light is on"); } else if (message == "false") { digitalWrite(PIN_LED, LOW); Homie.setNodeProperty(light, "on").send("false"); Serial.println("Light is off"); } else { return false; }

return true; }

HomieNode buttonNode("button", "button");

void loopHandler() { if ( digitalRead(PIN_BUTTON) == HIGH && buttonOLD == LOW) { digitalWrite(PIN_LED, HIGH); Homie.setNodeProperty(light, "on").send("true"); Homie.setNodeProperty(buttonNode, "pressed").setRetained(true).send("true"); buttonOLD=HIGH; delay(1000); // 1 second }

if ( digitalRead(PIN_BUTTON) == LOW && buttonOLD == HIGH) { digitalWrite(PIN_LED, LOW); Homie.setNodeProperty(light, "on").send("false"); Homie.setNodeProperty(buttonNode, "pressed").setRetained(true).send("false"); buttonOLD=LOW; } }

void setup() { Serial.begin(115200); Serial.println(); Serial.println(); pinMode(PIN_LED, OUTPUT); digitalWrite(PIN_LED, LOW);

Homie_setFirmware(FW_NAME, FW_VERSION);

light.advertise("on").settable(lightOnHandler);

Homie.setLoopFunction(loopHandler); Homie.setup(); }

void loop() { Homie.loop(); }


OpenHab Items

Switch wifiplug1 "Smart WiFi Outlet" (All) {
mqtt=">[OpenHab:devices/wifiplug1/light/on/set:command:ON:true], >[OpenHab:devices/wifiplug1/light/on/set:command:OFF:false]" }

Mosquitto Debug MQTT Message

devices/wifiplug1/$homie 2.0.0
devices/wifiplug1/$implementation esp8266 devices/wifiplug1/light/$type light devices/wifiplug1/light/$properties on:settable devices/wifiplug1/button/$type button devices/wifiplug1/button/$properties (null) devices/wifiplug1/$name Wifi Smart Outlet devices/wifiplug1/$localip 10.0.0.X devices/wifiplug1/$uptime/interval 120 devices/wifiplug1/$fw/name ecoplug devices/wifiplug1/$fw/version 1.0.2 devices/wifiplug1/$implementation/config {"name":"Wifi Smart Outlet","device_id":"wifiplug1","wifi":{"ssid":"XXXXXX"},"mqtt":{"host":"10.0.0.1","port":1883,"base_topic":"devices/","auth":true},"ota":{"enabled":true}} devices/wifiplug1/$implementation/version 2.0.0 devices/wifiplug1/$implementation/ota/enabled true devices/wifiplug1/$online true devices/wifiplug1/$signal 68 devices/wifiplug1/$uptime/value 4 devices/wifiplug1/light/on true devices/wifiplug1/button/pressed true

Things to do.

  • There is an onboard electrical usage chip feeding into GPIO12. Figure out and send it over MQTT so we can do nice charts in OpenHab

Thanks for reading.

* I maybe compensated for certain affiliate links. Thanks for your support.

Comments

PapaBA (author)2017-08-08

Here are a couple threads that might help with programming ECOPlugs that have ESP8266 modules inside:

http://homeautomation.proboards.com/thread/254/esp...

http://homeautomation.proboards.com/thread/255/sol...

Caution, not all ECOPlugs use ESP8266 modules. See this thread:

http://homeautomation.proboards.com/thread/256/hel...

PhilKE3FL (author)2016-09-16

I don't know about others, but I for one would like to see EVERYONE who writes a HACK piece put right up front WHY they are doing this. What is it we will gain by doing this hack? I think that will save everyone time since those not interested can skip it and those who would be interested can find out up front that they are interested.

Also, saying things like, "put jumpers: Ecoplug VCC to 3.3V on FT232..." as you've done above assumes that everyone doing this hack knows what you are talking about. I suspect that this is NOT the case and some photos and schematics with circles and arrows would come in very helpful for those not as familiar with the chips and board as you are.

Raphango (author)PhilKE3FL2016-09-16

I agree.... I think indeed it should explain its motivations. But it's still a nice project. =)

Mikkel1955 (author)Raphango2017-07-29

From reading about other people doing the same thing, you would want to do it to free you from being tied to one specific app to control these. It is one pathway to being able to control the plugs from Alexa or Google Home.

PhilKE3FL (author)Raphango2016-09-16

No argument there Raphango! Thanks to billm950 for doing it!

JohnH812 (author)2017-01-23

This is a few months old but I can't get this sketch to compile with the latest Homie.

#include #define FW_NAME "ecoplug" #define FW_VERSION "1.0.2"const int PIN_LED = 15; const int PIN_BUTTON = 13;int buttonOLD=LOW;HomieNode light("light", "light");bool lightOnHandler(HomieRange range, String message) { if (message == "true") { digitalWrite(PIN_LED, HIGH); Homie.setNodeProperty(light, "on").send("true"); Serial.println("Light is on"); } else if (message == "false") { digitalWrite(PIN_LED, LOW); Homie.setNodeProperty(light, "on").send("false"); Serial.println("Light is off"); } else { return false; } return true; }HomieNode buttonNode("button", "button");void loopHandler() { if ( digitalRead(PIN_BUTTON) == HIGH && buttonOLD == LOW) { digitalWrite(PIN_LED, HIGH); Homie.setNodeProperty(light, "on").send("true"); Homie.setNodeProperty(buttonNode, "pressed").setRetained(true).send("true"); buttonOLD=HIGH; delay(1000); // 1 second } if ( digitalRead(PIN_BUTTON) == LOW && buttonOLD == HIGH) { digitalWrite(PIN_LED, LOW); Homie.setNodeProperty(light, "on").send("false"); Homie.setNodeProperty(buttonNode, "pressed").setRetained(true).send("false"); buttonOLD=LOW; } }void setup() { Serial.begin(115200); Serial.println(); Serial.println(); pinMode(PIN_LED, OUTPUT); digitalWrite(PIN_LED, LOW); Homie_setFirmware(FW_NAME, FW_VERSION); light.advertise("on").settable(lightOnHandler); Homie.setLoopFunction(loopHandler); Homie.setup(); }void loop() { Homie.loop(); }

TracyDaub (author)2016-09-15

Is Homie compatible with Amazon Echo?

dtbarnett (author)2016-09-15

I'm confused. I don't see anything that looks like my FT232 in the pictures and I don't know what the device in the second picture is or where it comes from. Also, where could I find information on how to interface with the device to my cell phone? And, is the reason for doing this that it will prevent the device from calling home to China or something else?

zonkerharris (author)2016-09-15

As someone already hacking with Arduinos, and investigating the ESP8266 (wifi-built-in embedded controller), and learning how to make my own "connected home", I tip my hat for the clues in this instructable! However, I can see where it could be even better, if you could flesh it out with a few more pages...

A simple glossary, with a few links;

ESP8266 - https://en.wikipedia.org/wiki/ESP8266
MQTT - Message Queue Telemetry Transport, a lightweight TCP/IP msg protocol
ITTT - If This Then That, a way to set conditional triggers for devices
OpenHAB - a cloud service for Open Source "connected devices"
https://my.openhab.org/

Sure, folks can learn more with some brief Internet searches, but some folks could learn a lot from some more context around what YOU are using these remotely-controlled switches for (or suggestions for what others might use them for...).

Summary: You can buy cheap wifi-controlled plugs, but they contact a server in China... have you ever seen the Big Bang Theory episode where Walowitz connected the lights in their apartment to the Internet, so folks can turn them on and off, just because they could? Someone opened these plugs up, discovered the ESP8266 module inside, and figured out how you can connect wires, and reporgram it to not call China anymore, while letting you use the OpenHAB server to control these outlets. To do this yourself, you'll need to be able to solder, and have some experience using the Arduino IDE to program the chip using the code shown here. You'll also need to set up an OpenHAB account.

Thank you for posting the clueful information!

traveldoors. (author)2016-09-15

what is Homie 2.0 ?

where to find it

billm950 (author)traveldoors.2016-09-15

Download Homie from their Github Follow the read me on how to properly flash a configuration file from their readme.

tgvoss (author)2016-09-15

It would be helpful to some that are not as familiar with "Homie 2.0" & MQTT what this project is about in the beginning description. I have been learning about MQTT lately and still was a little confused what you were doing until I spent a half hour reading/researching what you are trying to do. Just a tip to try and help make this ible more accessible.

setsunakaede (author)2016-09-15

Hmmm..., this project looks nice, but... what IS it? Could you perhaps add some context to the story by telling what it exactly is and why we would definately make one (or two, or dozens...)? I am aching to know what this could improve for me!

rodwhittlehckqa (author)2016-09-14

NIce, which board should I select within the Arduino IDE for uploading the sketch?I'm guessing esp8266 generic?

billm950 (author)rodwhittlehckqa2016-09-14

Yeap, ESP8266 Generic works wonders.

About This Instructable

21,482views

136favorites

License:

More by billm950:ESP8266 Water Leak Detector MQTT HomieESP8266 Led Strip MQTT Control Lights WS2812ESP8266 Soil Moisture Sensor for $7
Add instructable to: