DIY: Cheap (~3€) ESP8266 based WiFi relay/switch with MQTT

Tags: #<Tag:0x00007f77f9a8ae30> #<Tag:0x00007f77f9a8ad68>

Hello there :slight_smile:

DISCLAIMER: I will take no responsibility for any of your actions or damage that may occur. This relay is powered by 5V, which is not harmfull at all, but if you decide to connect high voltage to relay terminals, do it on your own risk and be sure that you know what you’re doing.

Few months ago I had idea to control my central heating and hot water boiler with little WiFi relay, which I found on AliExpress for ~3€ (~$4) each (URL). The product name is LC Technology ESP8266 Relay, which, for my dissapointment, was not what I was looking for, because this relay is controlled via serial interface or crappy Android APP, also with no MQTT. Before throwing it out to trash can, I made a little research, and found out that with little soldering iron it can be converted to fully functioning WiFi relay and with MQTT support. Yayyy!! So, if you have the same model as I do - don’t throw it out yet (or go and pick it up from trash can). This is what you need to do. Conversion is as easy as urinating on two fingers (I’m bad at metaphors…). So let’s come on. Here are the steps.

  1. Remove ESP8266 module and put it aside, you’ll need it later.
  2. Grab tweezers and soldering iron, some fine wire (I used a thread from UTP cable) and 10kOhm resistor (can be found almost in any electronics, I found mine in old PIR sensor, colors are brown, black, orange, gold).
  3. Using soldering iron, gently remove chip named U4 and resistor R4 (See picture below).
  4. Solder piece of wire on resistor R3. You want it to solder it on pin, closer to capacitor C2. (See picture below).
  5. Now, other part of that wire we need to solder to ESP8266 GPIO0 pin. (See picture below)
  6. Last step is to solder 10kOhm resistor on VCC and GPIO0 pins. (See picture below)


Soldering places:

VCC and GPIO0 pins:

Hardware part is over. Lets begin with software part. For software part, I uploaded Sonoff-Tasmota firmware using PlatformIO. You can find information on how to compile and upload firmware on Sonoff-Tasmota Wiki. To get ESP8266 into flash mode, you need to short GPIO0 to GND, see example below:


After flashing is done, put ESP8266 back where it belongs, power on 5 volts to this bad boy and connect to your relay using web browser. Now basically what you want to do is to send signals (HIGH/LOW) to GPIO0 to control the relay. By default (almost?) all Sonoff devices uses GPIO0 for button. Luckily, you can find Wemos D1 mini in configuration list, where you can choose your GPIO0 device. So, configure your device as Wemos D1 mini, select D3 GPIO0 Button1 as 17 Relay1:

Save configuration and after relay reboot this masterpiece should work as expected. Configure MQTT and other settings according to your network and use it where you want it :slight_smile: I integrated one relay to my sound amplifier, so HA will power it when my TV is turned on.

Here is example HA configuration as switch:

  • - platform: mqtt
    name: amplifier
    command_topic: cmnd/amplifier/POWER
    state_topic: stat/amplifier/POWER
    qos: 1
    retain: True

I will gladly answer questions if you have any. Do not forget to triple check connections if you decide to use this relay on high voltage.



I havnt been able to find a guide for the one with the dual relay, could you perhaps guide me in the right direction?
I mean this one:

1 Like

Hi, Christopher, could you provide relay photo? Seems the link is broken.


Thats weird, it’s supposed to be a photo. Here it is again:

And here’s a link to the product page: Banggood Dual Wifi Relay

You can load tasmota on this and make it work with no hardware modifications.

Type the following commands into console

SerialLog 0

Rule 1

Rule1 on System#Boot do Baudrate 115200 endon
on Power1#State=1 do SerialSend5 A00101A2 endon
on Power1#State=0 do SerialSend5 A00100A1 endon
on Power2#State=1 do SerialSend5 A00201A3 endon
on Power2#State=0 do SerialSend5 A00200A2 endon

This is cool. Does this only act as instant on off or can duration be adjusted? I need something like this to let power through only for a 15 second burst and then stop. Thanks!

Hi all, first post new to HA and loving it.
Thanks everyone for all the help, pretty much everyone here has done something for me in vids and posts, i’ve been soaking up heaps!
i feel i can help here…

I worked this problem out with the 4 relay version of this board.
I tried the serialsend route but couldn’t get my MQTT server to play nicely when i used this method (this could be finger trouble, i’m very new to this!)
I ultimately ended up using a tasmota fork that natively supports these boards.
check it out at

i couldn’t get it to flashEZ so used Arduino IDE.
change device to LCtech 1 2 or 4ch - bung in MQTT details - job done.
it also has 2 GPIO’s available GPIO0 and 2, i guess these are the ones directly on the ESP1 module, nurse hand me some of that electrical string and a resistor, stat…

the question of timing the relay on and off.
This is a standard function of Tasmota.
dive into the console and use the pulsetime command to set time.

eg pulsetime1 2
this will switch on relay 1 for 2 miliseconds when sent the ‘on’ command. Good for powered gates, garage doors and that kind of malarkey.

more info on Tasmota commands - there’s not much she can’t do :slight_smile:

1 Like

Thanks so much for sharing evryone , and @Jon_ctrl , I’ve been following this thread for a solution on the 2/4 relay boards. Will give it a go soon! Thanks again! :slight_smile:

Hi, I have a 4ch LC module.
I can’t compile WESPOTA with Arduino. How should I prepare the Arduino IDE? The card should I put ESP? What folders do I need in the Arduino IDE to be able to compile WESPOTA? Do you have a BIN file that I can load with ESPtool ?? Thank you

I am away from home ATM so cant check my setup.
youtube - ‘ESP01 Arduino IDE settings’ to make sure you have the IDE setup correctly and have the correct pins shorted for programming these boards.
I don’t recall having any massive headaches flashing, so I would be tempted to confirm all settings and libraries are ready to go, make sure they are all in the same directory as IDE will grab them during the compile operation.
I will check out my notes when i get back and add to this if i find anything.
Good Luck :slight_smile:

Ok. I wait your information. Thanke tour.

what file should i open in the IDE? wespota.ino? is this file I only need to compile? of the folder that I downloaded wespota what is it for? do I have to copy the libraries, lib, src folders to the folder of my arduino ide ?? help please i’m stuck

Nice writeup! I followed the instructions and have an easy to control Tasmota based ESP-01 Relay now.
Thank you!

Dammit, i didn’t get back to you! :open_mouth:
Im sure it flashed much the same as Tasmota.
to see tasmota flashing with Arduino IDE and get the IDE set up correctly check this vid out
for the most part people dont use IDE to flash tasmota anymore but following this vid will get the pre-requisites installed and get Arduino IDE correctly configured to install wespota.
once you’re all configured…
download the entire wespota zip (top right)
open it - go into src
open wespota.ino in arduino ide
change settings under the wespota.h tab if need be
(essentially do the same stuff as you saw in the video but with the wespota image rather than the sonoff image)
Good Luck! let us know how it goes.

Non va assolutamente!! Ho speso molto tempo per farlo ma Arduino non compila assolutamente. Mi dà mille problemi di librerie e di altri errori. Appena risolvo uno ne spunta fuori un altro. Puoi inviare un file già compilato ? Vorrei provare a caricarlo con espeasy Direttamente. Grazie.!