Sonoff switches are one of the best deals in Home Automation.  A wifi chip with a relay that is powered by 110v for $5! And the BEST part is how flexible and capable they become when you flash them with TASMOTA firmware, which makes them easy to connect and control with Home Assistant.

Here are some links to buy Sonoff Basics:

https://www.itead.cc/sonoff-wifi-wireless-switch-1.html

or

https://tinyurl.com/SonoffBundle

 

Gotta give all the credit here to Theo Arends. He’s done us all a huge service by creating this firmware. Sonoff should totally pay him a gagillion dollars and start loading his firmware on all their boards.  

 

There are several guides that describe how to flash the firmware on these boards:

Quickpi – https://youtu.be/n4MDRm2yAJg

Bruh – https://youtu.be/-JxPWA-qxAk

SuperHouseTV – https://youtu.be/8mz5sCAvDAY

 

I tried 4-5 different methods.  What I finally got to work was using the Arduino IDE on Windows. I tried using Atom and PlatformIO, but kept getting errors. I tried Arduino IDE on my mac, but that didn’t work either.  Here are the steps that finally worked for me:

 

  1. Download latest TASMOTA Source Code zip file and extract it
    1. https://github.com/arendst/Sonoff-Tasmota/releases
  2. Download Arduino IDE and extract it
    1. https://www.arduino.cc/en/Main/Software
  3. Find the arduino.exe file and in the same folder, make a new folder called “portable”
  4. Open the Arduino IDE. Go to File>Preferences>Additional Board Manager and add this URL:
    1. http://arduino.esp8266.com/versions/2.3.0/package_esp8266com_index.json
  5. Under Sketch>Include Library>Manage Libraries search for and install ArduinoJson and PubSubClient
  6. In the “portable” folder you created go to sketchbook>libraries>PubSubClient>src> PubSubClient.h open it with Notepad++ or another code editor and change “MQTT_MAX_PACKET_SIZE” to “512”. Save and exit.
  7. In Arduino IDE go to the folder where you extracted the TASMOTA firmware, find sonoff>sonoff.ino and open it.
  8. Find the “user_config.h” tab at the top and make theses changes:
    1. Project is where it will define the MQTT topic.  So if you have more than one of these add a number to the end of each.
    2. Enter your Wifi name and password
    3. Enter your MQTT broker IP address, port, username and password
  9. Go to the Sonoff.ino tab again. Then under Tools set these settings:
    1. Board: Generic ESP8266 Module
    2. Flashmode: DOUT
    3. Freq: 40
    4. CPU: 80
    5. Flash: 1M (64K SPIFFS)
    6. Upload speed: 115200
    7. Port: Com (whichever number appears after you’ve connected the adapter and Sonoff)
  10. Set up and connect the Serial to USB converter.
    1. Buy here: http://a.co/7M6rBdG
    2. Make sure the adapter is set to 3v.
    3. Connect 4 Jumpers: 3v, Gnd, Tx, Rx.
    4. Tx (transmit) from the USB to Serial converter goes to Rx (receive) on the Sonoff, and vice versa.
  11. Leave the 3v wire free, hold the button on the sonoff, then connect the 3v wire. There will likely be a sound when Windows detects the new device.
  12. Now Upload the sketch. The sonoff light should blink when it is done.

 

Congratulations! You did it! (Hopefully)