The Sonoff is ESP8266 based and primarily used for it's WiFi capabilities, without the WiFi it's not much different to Arduino, it's programmed using the Arduino IDE too.
If you need WiFi and your trying to do something more custom (ie not just using it as a WiFi switch), then I would suggest not using Sonoff and using an ESP8266 dev board instead..... Like the CH340 NodeMcu V3, which is a bare bones ESP8266 PCB, powered by USB, but all the GPIO pins are available for whatever you want. The have more flash memory than Sonoff and are easier to flash custom firmware to, as iTead/Sonoff tried to stop people changing out their firmware, because they want people to DL their app with all it's invasive permissions.
They're cheap too, you can get 5 of them for the price of one Sonoff Basic, then all you need is some generic relay or SS relay modules, which are again very cheap.
I've got Sonoff switches and i've ended up modifying them and changing them to my own custom Firmware, to the point where buying Sonoff has ended up seeming pointless. One of them I removed the relay, so that I could switch low voltages, because on Sonoff the relays are connected to mains permanently.
Horses for courses and all that.