Economies of scale and mass production bring us tons of stuff for not much money. And sometimes, that stuff is hackable. Case in point: the $5 Sonoff WiFi Smart Switch has an ESP8266 inside but the firmware isn’t very flexible. The device is equipped with the bare minimum 1 MB of SPI flash memory. Even worse, it doesn’t have the I2C ports exposed so that you can’t just connect up your own sensors and make them much more than just a switch. But that’s why we have soldering irons, right?
[Jack] fixed his, and documented the procedure. He starts off by soldering a female header to the board so that he can upload his own firmware. (Do not do this when it’s plugged into the wall, you could get electrocuted. Supply your own 3.3 V.) Next, he desolders the flash memory and replaces it with a roomy 4 MB chip, because he might want to upgrade the firmware over the air, or just run some really, really big code. So far, so good. He’s got a better version of the same thing.
But breaking out the ESP8266’s I2C pins turns this little “switch” into something much more useful — a wall-powered IoT sensor node in a sweet little package, with a switch attached. It’s just a matter of tacking two wires onto the incredibly tiny pins of the ESP8266 package. The good news is that the I2C pins are on the edge of the package, but you’re going to want your fine-tipped iron and some magnification regardless.
That’s it. Flash in a better firmware, connect up whatever I2C devices you’d like, and you’ve got a very capable addition to your home automation family for just a few bucks. Just for completeness, here’s the warning again: this device uses a non-isolated power supply, so if the neutral in your wall isn’t neutral, you can get shocked. And stay tuned for a full-length article on transformerless power supplies, coming up!