Hi
There are a lot of cheap more or less "smart" wifi plugs out there and most of them are esp8266/esp8285 based.
I picked the cheapest I could find on Amazon prime and for this showcase I'll flash the Tasmota firmware on it.
Alternative firmware for ESP8266 based devices like iTead Sonoff with web UI, rules and timers, OTA updates, custom device templates and sensor support. Allows control over MQTT, HTTP, Serial and KNX for integrations with smart home systems. Written for Arduino IDE and PlatformIO.
.
WARNING BEFORE PROCEEDING
DO NOT CONNECT DEVICES TO MAINS POWER WHILE THE COVER IS OPEN AND CIRCUIT BOARD IS EXPOSED!!!
NEVER TRY TO FLASH WHILE YOUR DEVICE IS CONNECTED TO MAINS POWER!!!
YOU CAN BE ELECTROCUTED IF YOU DON'T KNOW WHAT YOU ARE DOING!
.
Let's start with the plugs on Amazon.
The description says that the plugs got wifi, timer functions, remote control and that you don't need a hub.
Further down it also says IFTTT compatible.
So I figured they are probably esp8266 based and ordered 2 of them
That's how they look like
Next thing to do is to open them and that is a bit of a pain in the butt. The case of the plugs is glued and not screwed
So I opened them with the help of a screwdriver and a spudger
Now I remove the pcb
Here you can see the wifi module which unfortunately has no module name printed on
so I remove the shielding
and as you can see it turns out to be a ESP8285 module. You don't have to remove the shielding - I just did it so I know what I'm working with.
Now I'm preparing everything for the flashing part.
First I have to know the pinout of the module. Fortunately the pinout is printed on the back of the module
I have to solder a wires to the 3.3V, GND, RX, TX and GPIO0 pin in order to connect it to a usb to serial converter. It doesn't matter if I choose the pins on the one or the other side of the module as long as they match the pin I want.
Now I connect the wires to the usb-serial converter. The RX and TX wires have to be crossed. Most important is to use 3.3V and not 5V or you might fry your esp module
(GPIO0 wire is missing in this picture)
After powered on by the converter the led starts blinking. The esp module is running its stock firmware.
Now I set the module into flash mode by connecting GPIO0 to GND (disconnect the converter from usb before that)
and connect the converter again. This time the led doesn't blink. Disconnect GPIO0 from GND after like 10 seconds. Now everything should be ready to be flashed.
As flashing tool I use NodeMCU-PyFlasher-4.0. Configure it like I did (COM port my vary)
Download a firmware with your favourite language here, load it and flash it
And that's it The plug is now running on Tasmota firmware.
Now you can connect the plug with your wifi.
Search with your smartphone or laptop for a new wifi with sonoff
in the name and connect to it.
Now open your webbrowser and let it connect to the wifis login page
search for your home wifi and enter the password and click on save. The plug should now be connected with your wifi.
Check for the ip of the plug on your router and then enter it into your browser.
You should be welcomed by this
The following configuration is specific to this device.
Click on configuration -> configure module. Change the device typ to generic and save it. After the device rebooted set the following pins:
I found the used GPIO pins by following the traces on the pcb to the led and the button. First the led didn't work as it should so I changed it to the inverted led option (Led1i)
Now we just have to desolder the wires and assemble the plug again
aaaaaaand done
Special thanks to @foosel. She provided assistance while I was doing this