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:
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:
- Download latest TASMOTA Source Code zip file and extract it
- Download Arduino IDE and extract it
- Find the arduino.exe file and in the same folder, make a new folder called “portable”
- Open the Arduino IDE. Go to File>Preferences>Additional Board Manager and add this URL:
- Under Sketch>Include Library>Manage Libraries search for and install ArduinoJson and PubSubClient
- 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.
- In Arduino IDE go to the folder where you extracted the TASMOTA firmware, find sonoff>sonoff.ino and open it.
- Find the “user_config.h” tab at the top and make theses changes:
- 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.
- Enter your Wifi name and password
- Enter your MQTT broker IP address, port, username and password
- Go to the Sonoff.ino tab again. Then under Tools set these settings:
- Board: Generic ESP8266 Module
- Flashmode: DOUT
- Freq: 40
- CPU: 80
- Flash: 1M (64K SPIFFS)
- Upload speed: 115200
- Port: Com (whichever number appears after you’ve connected the adapter and Sonoff)
- Set up and connect the Serial to USB converter.
- Buy here: http://a.co/7M6rBdG
- Make sure the adapter is set to 3v.
- Connect 4 Jumpers: 3v, Gnd, Tx, Rx.
- Tx (transmit) from the USB to Serial converter goes to Rx (receive) on the Sonoff, and vice versa.
- 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.
- Now Upload the sketch. The sonoff light should blink when it is done.
Congratulations! You did it! (Hopefully)