How to add an I2C interface to a Sonoff WiFi Smart Switch.
The Sonoff brand is a whole series os IOT devices that use the esp8266 WiFi processor internally. The devices are easily hacked and are cheap. The Sonoff WiFi Smart Switch is the most straightforward device, which can turn on or off 110/220 Volt 10 Ampere remotely. That means you can have your ceiling fan, lamp or anything else connected t mains power remotely controlled by your phone or computer. But the software that comes with it isn’t very flexible and cannot be integrated into a home control system like NodeRED, OpenHAB or any other home automation system.
Firmware
The Sonoff devices are easy to hack, so you can put a better firmware like ESPEasy on it and integrate the device with any system. ESPEasy has an extensive list of extra modules that you can connect, like temperature, barometric pressure, humidity, light sensors, PIR sensors and a long list of other things.
But most modules connect with I2C, which is a serial interface for interconnecting ICs using a clock and a data line. The Sonoff Switch only have one extra pin available, making it impossible to connect more advanced sensors. But there is a way of fixing that. Here’s how to add that to add an I2C connector to your $5 Sonoff and open up a whole field of stuff you can do.