====== Sonoff Smart WiFi Switch ====== {{ :esp8266:sonoff_03.jpg?200 |}} The Sonoff Smart WiFi Switch is a very inexpensive (~$6 on Alibaba and ~$8 from US vendors (eBay or Amazon) WiFi controlled relay. \\ It operates directly from AC power (110 or 220) and drives a 10A relay. \\ The main feature of the device is that it uses the ESP8266 System-on-Chip which integrates a WiFi radio and a 32 bit microcontroller on board. \\ The ESP8266 can be programmed a number of different ways. The one I have experimented with is the Arduino IDE. More on that later. \\ The Sonoff Switch is intended to be operated from an Android (and iPhone) app named Ewelink. I found the app very disturbing, the apk is about 35MB and the app asks for absolutely every permission possible on Android. It is not clear to me why a WiFi relay (On, Off people...) need to have access to my camera, microphone, phone book and so on, so the app had to go. \\ Which led me to experiment with the Arduino IDE to reprogram the chip. I have been waiting for a good opportunity to do something with the Arduino IDE, but the traditional Atmel based devices are not really appealing to me since I have a lot of experience and code for the 8051 (particularly those made by Silabs). The ESP8266 is in a different category and not being keen to have yet another 32 bit toolchain installed on my computer (I already have Eclipse which I am using with the NPX ARM Cortex M3 chips), I thought this would be an excellent opportunity. There is a bi-color LED on board even though only the green LED is used in the WiFi application. It looks like the PWB can also accommodate a 433MHz receiver and be operated from a battery operated remote controller and the red LED is used in that application. The schematic is available from Itead, the manufacturer of the device [[https://www.itead.cc/wiki/images/f/f8/Sonoff-Schmatic.pdf|Sonoff Basic Schematic]]