Introduction: 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

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.