📖 Summary
So in this tutorial I'll show the following steps to reproduce the flashing of Sonoff Slampher v2 and an optional step requiering a 3D printer in order to print a custom case for the board
- Opening the Sonoff Slampher
- Locating required pins to solder on
- Setting up your YAML file
- Flashing the board with
esphome - Pairing the board with your home assistant
- Optional: Printing a custom case for the board
⚠️ Warning
You're dealing with live electricity, either 110V or 220V depending on your country.
The device has capacitors on the board, so be careful not to short them and leave the board disconnected from the power source for at least 10 minutes before working on it.
If you repurpose the board as a smart switch, just keep in mind that the board has a maximum load of 450w @ 2A for 220v or 220w @ 2A for 110v.
📋 Prerequisites
- ✅ Sonoff Slampher v2.x
- ✅ Soldering iron is strongly recommended to secure the connections
- ✅ Philips screwdriver
- ✅ Your favorite text editor
- ✅ ESPHome installed on your machine
- ✅ USB TTL Serial Converter (like this one)
1. 🪛 Opening the Sonoff Slampher
The first step is to open the Sonoff Slampher.
- Unplug the Sonoff Slampher from the power source and wait for at least 10 minutes to discharge the capacitors
- Locate the two screws on the top of the case and remove them with the Philips screwdriver
Lift the case up and make sure not to lose the screws and don't force the case off, it should come off easily. Wires are pretty strong, but don't pull them too hard. If you plan to repurpose the board as a smart switch, you can cut the wires to the desired length or desolder them from the board/sockets.
2. 🔌 Locating required pins to solder on
The next step is to locate the required pins to solder on.
You'll need to find 5 pins on the board to solder on.
| Pin | Description |
|---|---|
GND |
Ground |
3V3 |
Power |
RX |
Data (receiver) |
TX |
Data (transmitter) |
GPIO 0 |
Reset on R3 unpopulated pad |
Here's a picture where you can find them:
I suggest you soldering Dupont connectors to the board in order to have a more secure connection and easier to (re)use.
Then solder a jumper wire to the R3 that can be connected to the USB TTL Serial Converter's
GND pin in order to be able to start the board in flashing mode.
Once you've soldered the pins, you can connect the USB TTL Serial Converter like so:
| Pins from the board | Pins from the USB TTL Serial Converter |
|---|---|
GND |
GND |
3V3 |
VCC |
RX |
TX |
TX |
RX |
R3 (GPIO 0) |
GND |
3. 📝 Setting up your YAML file
The next step is to setup your YAML file.
You can download the sonoff-slampher-example.yml from this repository and edit it to your needs.
Here's what you need to change:
🔧 General settings
The name of the device and its friendly name for Home Assistant.
esphome:
name: <your-device-name>
friendly_name: <your-device-friendly-name>
🔐 Authentication settings with Home Assistant
The encryption key and the reboot timeout that will be used to authenticate the device with Home Assistant.
api:
encryption:
key: "MZjX7hoxB43MeKI8MsLdKTjzduEUjRU9sH4TGtFCmKX="
reboot_timeout: 0s
📦 OTA settings
The OTA (Over The Air) settings are used to update the device firmware from the ESPHome dashboard.
ota:
- platform: esphome
password: "de82ddbe2bebb6010a721fd2451684d6"
🛜 WiFi settings
The WiFi settings are used to connect the device to your home network.
wifi:
ssid: "<your-wifi-ssid>"
password: "<your-wifi-password>"
min_auth_mode: WPA2 # Required for next ESPHome updates. Please check the ESPHome documentation for more details.
📡 Access Point settings
The AP settings are used to create a local access point for the device if the WiFi connection is not available.
ap:
ssid: "<your-ap-ssid>"
password: "<your-ap-password>"
For the rest of the file, you can keep the default settings provided in the example file.
4. 💻 Flashing the board with esphome
Here you have two options, you can either use the ESPHome CLI or the ESPHome dashboard inside your Home Assistant instance.
Since I'm have issues with the ESPHome dashboard inside my Home Assistant instance, I'll use the ESPHome CLI to flash the board. But I'll show you how to do it with the dashboard as well.
First of all make sure your board is in flashing mode by connecting the USB TTL Serial Converter to the board and the GND pin to the R3 wire that you soldered on as well as the other pins as explained at the end of the 2. 🔌 Locating required pins to solder on section.
⚠️ Warning
Make sure your USB TTL Serial Converter is in the correct voltage for your board. In most of the adapters, you'll find a switch or a jumper Dupont connector to switch the voltage between 3.3V and 5V. Make sure to use 3.3V for the board otherwise YOU WILL FRY YOUR BOARD.
📦 Using the ESPHome CLI
- The first step is to install the ESPHome CLI.
# Using python pip install esphome# Using brew on macOS brew install esphome# Using apt on Ubuntu sudo apt install esphomeFor other operating systems, please check the ESPHome documentation for more details.
- Connect the USB TTL Serial Converter to your computer and the board to the USB TTL Serial Converter.
- Type the following command to flash the board:
esphome run <your-yaml-file>.yml
- Wait for
esphometo download all dependencies and select the correct board and port (generally pick option 1).
- Wait for
esphometo flash the board.
If everything went well, you should see the following output:
INFO Successfully uploaded program.
- Once the board is flashed, you can unplug the
R3wire from the GND pin and disconnect/reconnect the USB TTL Serial Converter in order to setup it in the Home Assistant configuration.
🏠 Flashing the board with the Home Assistant ESPHome integration
- Open your Home Assistant instance and go to the
ESPHome Buildertab. - Click on
+ New deviceon the bottom-right corner and selectImport from fileand select your YAML file created. - Click on
INSTALLand wait for the device to be installed. - Select the board from the list of devices.
🔗 Pairing the board with your Home Assistant
If everything went well, you should be able to add the device to your Home Assistant instance. You'll need to copy the API key from the device settings and paste it in the Home Assistant configuration.
- Open your Home Assistant instance and go to the
Devices & Servicessection. - Your new device should automagically appear in the
Devices & Servicessection. Click onAdd
- You'll be prompted to enter the API key. Enter the API key you copied from the device settings and click on
Submit. - Now you're good to go! You should be able to control the device from your Home Assistant instance.
6. 🖨️ Optional: Printing a custom case for the board
If you want to print a custom case for the board, you can use the sonoff-slampher-case.stl and sonoff-slampher-cover.stl files from this repository. You can also download
the Fusion 360 file from this repository and open it with Fusion 360 to edit the design.
You'll be able to reuse the original screws to close the case.
Here's some parameters used to print the case:
| Parameter | Value |
|---|---|
| Filament type | PLA |
| Filament color | White |
| Filament brand | Amazon Basics |
| Bed temperature | 50°C |
| Hotend temperature | 200°C |
| Print speed | 150mm/s |
| Layer height | 0.28mm |
| Support | Yes |
🎉 Congratulations!
You've successfully flashed your Sonoff Slampher v2 and paired it with your Home Assistant instance.
If you need any help, feel free to open an issue on this repository or contact me via email at mcamus.dev@gmail.com.