If you want to build a smarter house for your home, like a scheduled garden lighting, a remote gate opener, even create or open a door lock with an application via internet connection, then perhaps a smart switch from Sonoff can be the answer for that.
What is Sonoff and Sonoff Basic
Sonoff (https://sonoff.itead.cc/en/) is a brand that focuses on creating IoT (Internet of Things) devices for home appliances. Sonoff has various devices such as smart sockets, smart lamp switches, etc and the most basic one is the Sonoff Basic.
Sonoff Basic is basically a wire switch that is connected to a homes WiFi and can be accessed via internet connection to turn the power on or off.
You can get Sonoff Basic from Amazon for $5 US. Let’s try to configure this device and we will see the wide possibilities on the application in your home.
Setting Up
Open the input and output covers from your Sonoff device, and put the wires in both sides of the input and output sections.
After the wire installation is ready, you need to download the eWeLink app on Android or IOS to your smartphone to control the switch later.
Pairing
After you have installed the Sonoff Basic with the cable power input and output like shown above, you are then ready to pair the device with your wifi network. To do that open the eWeLink app you have installed on your smartphone, register a new account, and the app will send you the link to finalise the registration. Follow the steps shown then after you successfully login to the app, prepare the cable installation by plugging it to the power outlet.
Press the black button on the device near the LED lamp for about 5 seconds until the LED is blinking. It indicates that the device is ready to be paired. Open the eWeLink app, and click the ‘+’button on the bottom centre of the app, then click ‘Quick pairing’ button to continue the steps.
Set the wifi connection name and password in the next step then click the ‘Next’ button and let the app pairing between device and wifi begin. When the app succeeds in pairing, you can name the device in the last step to identify it later. When you have more than 1 device registered in the eWeLink app device with meaningful naming will really help identify your IoT device.
Controlling the Device
After you successfully add Sonoff Basic into the eWeLink app, the device will be listed. You can now turn the switch On and Off by the tap of a button!
The eWeLink has the other useful options like Schedule, Timer, and Loop Timer.
Video: https://photos.app.goo.gl/VhffXXoGuWznknS4A
What’s Next from Here?
You can create another similar remote control project based on the above concept, for example a simple door lock system using electromagnetic/selenoid door lock that can lock and unlock based on power.
You can also integrate eWeLink further with home assistant devices like Google Assistant, Amazon Alexa, or Mi Home. This would enable you to activate the Sonoff device with voice commands.
Video: https://photos.app.goo.gl/YErjT4kv7uSkyAiD6
If you are looking for a harder challenge, you can install a hacked version of the firmware that is ready to read data from additional sensor modules such as aa humidity sensor. Better yet, use your own local WiFi to pair it with a local nodejs webserver that you can put on a Raspberry Pi.
This means you don’t need eWelink to act as a cloud server anymore enforcing device and data security. Just set the wifi of your server as your new Access Point, pair Sonoff to that AP, and create your app that will control the device inside the new network.
Or if you just want to create your own presentation layer app but without creating a whole new server, you can still use eWelink but just access the eWeLink server via web hooks. Check out IFTTT (https://ifttt.com/discover) it has some applets/code snippets that is ready to be used to access your Sonoff device that is already paired and stored inside your eWelink account.
Further Reading
https://www.jackenhack.com/sonoff-switch-i2c/
https://www.hackster.io/TechGuru/sonoff-control-from-any-web-application-or-page-d5f6cd
https://blog.ipsumdomus.com/sonoff-switch-complete-hack-without-firmware-upgrade-1b2d6632c01
https://www.instructables.com/id/Control-Sonoff-From-Raspberry-Pi/