About a couple of months back a work buddy of mine, moved back to Canada and  gave me 4 Sonoff switches, he was using the Sonoff to control his lamps using the default sonoff mobile app. I dint want to use the mobile app, to send data to the cloud, and after a couple of search’s on the internet found they use an ESP8266, which means if you are able to locate the pads you can re-program it, to load your own firmware . On Github there are repositories which you can use to flash the Sonoff switches with a FTDI cable and the Arduino IDE, but before I get to using those I wanted to write a small webpage/web-server to flash the Sonoff, using the Arduino IDE. My goal with this project is to use all the 4 Sonoff’s that I have and connect them to 3 Lamps I have in my apartment, and have one connected to my old air conditioner in the apartment to switch it on at 5 PM in the evening if the temperature from the Openweather map API is greater than 80 F, so that it is nice an cool when I am back home.. In addition,  for master device I plan to either us Home-Assistant(https://www.home-assistant.io/) on a Raspberry Pi 3, with the Sonoff switches as MQTT client. OR use MKR WIFI 1010 as a MQTT server, with the Sonoff switches as MQTT client.


On inspection of the Sonoff, there are pins located at the back which you can use the flash the ESP8266, here is list of pins

  • GND
  • TX
  • RX
  • Vcc 3.3V
  • IO2


I soldered on some two pin headers, so that I can connect a FTDI cable with ease.


While flashing using the Arduino IDE, to place an ESP8266 into program mode, you will to follow the sequence of steps-

  • If you are connected AC power, disconnect before following the steps below
  • Connect FTDI cable to the soldered pin
  • Open the Arduino IDE on your computer
  • Hold down the tall switch and then connect the USB cable to your computer
  • Let go off the switch and upload the sketch using the Arduino IDE

Code and Video is still a work in progress…