The Sonoff Slampher is a very interesting product for you domotica project if you don’t want to be to invasive in your electric system.
Factory default the Slampher has some descent software with a nice app, but if you want more for example connect is to your Mqtt broker you need to change the firmware.
If you want to program your own software or other software the can be found on the internet then you have to reprogram the ESP8285 inside

There are enough tutorials on the net how to reprogram the Slampher, however the Slampher that I bought on Ali Express is a new V2.0.
This version has an ESP8285 on board in staid of the famous ESP8266. The ESP8285 is ruffly the same as the ESP8266 except that it has an build in 1MByte flash memory.
With the Arduino ide the ESP8285 can also be programmed, luckily

Lets start;
To get the ESP8285 in flash mode we need to connect GPIO0 to the ground. To connect the button on the Slampher to GPIO0 we need to move a resistor. Normally the button is connect to the RF part to learn the Slampher the rf remote. We want to program the ESP8285 and for that move R21 to R3. It’s an 0Ω resistor so a piece of wire or solder will also do the job.
After that you need to connect your usb to serial convertor.  Pin 1: Vcc, 2:rxd, 3:txd and 4:gnd . The ESPxx works on 3V3 so don’t fry it with the 5V output of your convertor.
My convertor didn’t have enough mA to supply the Slampher direct so that’s why you see on the pictures a separate 3V3 power supply.
Press the button and insert the usb convertor in your computer and happy flashing.
Don’t connect the Slampher to the mains for your safety.
Personally I add to all my ESPxx programs the OTA (over the air) flash capability’s so you can remove the usb to serial convertor and close up the housing for safety purpose and flash new firmware ota.
The relay won’t work if you not connect the Slampher to the mains, it needs the 5V from the transformer.
Here is a small sample on GitHub to get is working, button, relay, ledgreen are supported. Ledred and the rf receiver are not (yet) supported.

Arduino ide settings:
Gerneric Esp8285 Module
CPU Frequency: 80MHz
Flash Size: 1M (64K SPIFFS)
Upload Speed: 115200