2017_10_04 Update: If the flashing method in this first post does not work for your device, try the method mentioned in this post:
2017_05_10 Update: Sonoff Dual - Firmware and device handler and child device handler. Flashing info here. Sonoff 4CH - Firmware and device handler and child device handler.
2017_01_21 Update: Release of firmware and SmartApp updates for the Sonoff Touch and Sonoff S20. Picture for flashing Sonoff Touch in this post.
2016_10_14 Update: I have been playing with the Sonoff TH (16 Amp Version) and am finished with a SmartThings capable firmware for it. This device has a 10 & 16 Amp version and support for a temperature sensor attachment. The device handler supports both temperature and humidity. Here is the firmware & here is the device handler. You also need to install the Sonoff (Connect) SmartApp posted below.
2016_06_02 Update: I have created a custom firmware and service manager for these switches. I was able to really simplify the setup and significantly reduce the code footprint for the firmware. I wanted to update this main post but leave the old information for those that may still be using it. Still trying to figure out how to do that in a non-confusing way. Right now if you search Google for “Sonoff SmartThings” you will find my blog post with the old instructions. If you want to update from the old EasyESP firmware to this new one. Just go to http://ipaddressofswitch/update and upload the .bin image posted below. You don’t need to connect via FTDI if you already have the EasyESP image flashed. Also, any subsequent update from me will be updated the same way. After switching over to the new firmware you will have to reconnect to Wifi, but this will be a one time process.
This is a wifi relay that can be found for as low as $5. I have had a few of these up and running for a little while now and they are working great. They can even support instant status updates when the switch is toggled by pressing the button, and are really quite simple to setup.
Warning: Do all of the flashing before connecting the switch to mains electricity. Be safe when working with electrical devices. I take no responsibility if you do something that damages yourself or your property.
Flashing Firmware
This step is extremely easy, so don’t let it intimidate you. I have built custom image (with the inclusion of a couple of esp8266 Arduino libraries) for the switch to interact with SmartThings. First, download the ESPEasy firmware flashing tool. You will use esptool.exe from this zip to flash the firmware. Next download the firmware image that I have built here, and place it in the same directory that you extracted the esptool.exe binary. Now, with an FTDI adapter (SET AT 3.3V) connected to the switch (square pin = VCC, then TX, RX, GROUND - that order), plug the FTDI adapter into the USB port of your computer while holding down the button on the switch. This puts it into programming mode. Run the following command (make sure to replace %comport% with the comport number of your FTDI adapter i.e. COM6):
esptool.exe -vv -cd nodemcu -cb 115200 -cp COM%comport% -ca 0x00000 -cf Sonoff.ino.generic.bin
Connect to Your Home Wifi
Now, plug the switch into power and wait for a moment. It should create an access point named Sonoff.[macAddressofSwitch]. Connect to that access point with the password: configme and it should redirect you to the page where you can connect it to your access point. If it doesn’t redirect you the IP address is 192.168.4.1. Put in your network access point information and hit connect.
The switch should then connect to your Wifi access point.
SmartThings Setup
Add the device handler to your account:
Also add the Service Manager SmartApp:
Install the SmartApp from your mobile device and let it discover the switches connected to your network. It uses SSDP, so unless you have something funky configured on your network they should show up. With the service manager there is no need to set static IP addresses or DHCP reservations for the switches. If the IP addresses change, the service manager should update them.
That’s it. Try it out and let us know how it goes.