[Guide] How to flash a Sonoff Basic R3 OTA (eWeLink -> ESPHome) and setup HA in docker

Tags: #<Tag:0x00007f739aa6b188> #<Tag:0x00007f739aa6b098> #<Tag:0x00007f739aa6afa8>

I recently went to visit my parents who have one of my old Pi 3’s running OMV 5 for a local Plex server to allow them to stream music around the house. I thought this would be a good opportunity to entice them into the world of home automation.

This is by no means a comprehensive guide but it aims to outline the process for getting up and running (potentially on existing hardware). If possible, rather run Home Assistant (I think it was called Hass.io).

Part 1: Setting up Home Assistant Core and ESPHome in docker

  1. Assuming that Docker is installed. SSH into the Raspberry Pi and run the following command to pull and run the latest container, the only thing you need to change is the path to your config directory.
docker run --init -d --name="home-assistant" -e "TZ=Africa/Johannesburg" -v /PATH_TO_YOUR_CONFIG:/config --net=host homeassistant/raspberrypi3-homeassistant:stable
  1. Head over to a web browser on your local machine and enter <your Pi’s IP>:8123 to setup Home Assistant.

  2. I couldn’t find documentation on which version of ESPHome to run on a Pi without using the Python installer but this one worked for me. Follow the same approach as step 1:

docker run --init -d --name="ESPHome" -e "TZ= Africa/Johannesburg" -v /PATH_TO_YOUR_CONFIG:config --net=host esphome/esphome-armv7:latest
  1. As you did in step 2, head over to <your Pi’s IP>:6052 in your web browser to setup and configure devices in ESPHome. NOTE: You do not need to setup the ESPHome integration in Home Assistant, devices will pop up in HA auto-magically - thanks HA team :slight_smile:

  2. Setup your device in ESPHome and download the .bin file. Save this for later.

Part 2: Time for the hardware, I bought a Sonoff R3 to give the DIY mode a try

  1. Download and install the eWeLink app on your phone/tablet. I used a 10 minute mail account to sign up and login - them Chinese don’t need any more of my info.

  2. Connect the Sonoff to AC power and add it to your eWeLink app

  3. In the eWeLink app, go to Device Settings and update the Sonoff’s to the latest firmware (this should be v3.5). My Sonoff came with firmware v3.0.0 which resulted me pulling my hair our for about an hour. Please learn from my mistakes :confused:

  4. Delete/reset the Sonoff from the eWeLink app

  5. Disconnect the Sonoff from AC power (once again, learn from my mistakes), pop the cover off and connect the supplied jumper onto the J1 header, labelled “OTA_SW”.

    Disclaimer: not my image. Thanks Tasmota team.

  6. Put the case back onto the Sonoff and connect it to AC power. Once it has booted, press and hold the button on the Sonoff until the blue light starts to blink rapidly

  7. Connect to the Sonoff’s Access Point (named ITEAD-XXXXXXXX) with the password 12345678`

  8. In your browser, go to to enter your 2.4ghz WiFi network name and password. Your Sonoff will reboot and connect to your AP once this is complete.

  9. Time to boot into Windows :frowning: . Download the tool for flashing custom firmware from Sonoff’s github repo – https://github.com/itead/Sonoff_Devices_DIY_Tools/tree/master/tool. The tool is tool_01DIY85(3.3.0).exe which implies that it works with Sonoff firmware v3.3 but I had no problems getting it to work on v3.5.

  10. Run the flashing tool, it should find your Sonoff. Click on the “Firmware Flash” button and select the .bin file that you created in ESPHome earlier. Select your Sonoff device, click “Flash Device List” and then hit “OK”. This will upload the firmware onto your Sonoff and reboot it once complete.

  11. Head over to Home-Assistant where you should see you a notification for your new device. Follow the prompts to setup the device and you’re good to go!

1 Like

Can you share your esphome config settings? I will be getting my first sonoff r3 soon.

Have a look here - it’s pretty well documented.

Shout if you have any questions.

Thanks. I have gone through the steps. I have an Ikea floor lamp I want to make smart. Since the sonoff is meant to act as a switch, I found this post where you can convert it to a light rather a switch in HA. I can just use this config file for my setup? Also, the black button on the sonoff is an on/off button? That is I can use it to turn on/off the lamp manually?