The "Joinrun Smart Wifi" socket with USB is another ESP8266 based wifi controllable power socket.
It comes with a pleasing design, a small form factor and with an additional USB charging port. It needs the smartlife app to control it via a china hosted server from your smart device and there are skills to work with the smart home assistants from amazon and google. It needs internet connection though and if you want to keep your home control inside your own network you can flash the controller with a different software like tasmota. Tasmota adds a web server to the device so you can directly control it from a browser in your home network.
Step 1: Opening the Case
There are 2 screws behind the cover plate at the bottom which need to be removed to open the case.
Step 2: Accessing the Esp8266ex Module
The device has no built in program header, so to flash it you need to solder programming wires.
The ESP8266 is on a separate board which is soldered perpendicular to the main board.
Unfortunately the programming enable pin (GPIO0) is not easily available.
So you need to contact it directly on the board.
I unsoldered the ESP board from the main board using desoldering braid.
Then I soldered a small wire to the GPIO0 pad.
The other programming pins are available on the board pads as shown on the picture.
Step 3: Prepare Flashing the Device
To flash the device I used a cheap USB-to-Serial adapter from aliexpress
The CP2102 MICRO USB to UART TTL Module comes with a 6 pin header and can work with 5V and 3.3V devices.
If you plug it into your windows PC it creates a COM port which you can see in the device manager.
Mine is at COM6 and I configured the port to 57600 baud.
Unplug the CP2102 from your PC and hook it up to the ESP module.
Connect 3.3V and GND to the corresponding pads on the ESP module.
Connect TxD to RxD on the module and RxD to TxD respectively.
To enable programming mode the GPIO0 must be pulled to GND e.g. with a 2k resistor.
Step 4: Prepare Your Programming Environment
There are many ways to flash an esp8266 module and to describe them in full is beyond the scope of this instructable.
Just use your favorite search engine to look for details.
I use the arduino programming IDE where the esp8266 board can be added from the board manager menu.
This then installs an esptool.exe which can be used to easily flash a binary to the ESP module.
The tasmota binary sonoff.bin can be downloaded from github.
It is also available in various languages.
Step 5: Flash Programming the ESP Module
The actual flashing can easily be done from a command prompt on windows.
Go to the folder where the esptool.exe is located
e.g. cd /d %USERPROFILE%\AppData\Local\Arduino15\packages\esp8266\tools\esptool
Then flash the device with the downloaded sonoff binary like this
esptool.exe -vv -cd nodemcu -cb 57600 -ca 0x00000 -cp COM6 -cf %HOMEPATH%\Documents\Downloads\sonoff.bin
Step 6: Configure the Module
After successful flashing the GPIO0 pin needs to be released from GND and the ESP repowered.
It then opens an access point and can be connected with a browser at 192.168.4.1
On the initial config page you can scan your wifi, select the appropriate network and enter your wifi password.
Then another reboot and the ESP will show up on your selected network.
Check the network in your router to find the assigned IP address.
Then connect to the IP with your browser and set the device type to "18 generic" and save it.
The ESP does an automatic reboot after which you can configure the relay and button ports as shown on the picture.
You may also want to go to "other settings" to set a friendly name, to disable MQTT if you don't have it and to enable the Belkin WeMo emulation to make the plug work with Alexa.
After everything works finally re-solder the module to the main board and re-assemble the plug.