In this post, you’re going to learn how to control an outlet from anywhere in the world using the Sonoff device. The Sonoff is a device that you put in series with your power lines allowing you to turn any device on and off.
First, watch the step by step video tutorial below
It’s very simple, it has an input in one side and an output on the other side.
Then, you can simply send commands via wifi to turn on and off. That’s pretty much how it works.
Opening the Sonoff
Let’s take a look inside the sonoff device. These are the main sections:
- There are the two powerlines and they are isolated from the rest of the circuit
- The active line goes to the relay (that’s on the other side of the PCB)
- The ESP8266, that is the processor that provides wifi and receives the control commands
- The Sonoff is meant to be hacked and you can see clearly that those 4 connections were left out, so that you can solder some pins and upload a custom firmware
In this project, we’re going to use the standard firmware that came with the Sonoff. In future post I’m going to show how to flash a custom firmware into the Sonoff device.
Let’s take a look at how this would fit in a normal circuit. Basically you cut the wire that goes to the device, and you put the Sonoff in the middle, so that you can control any device that is connected on the other end.
Normally, what you have is a power source that has an active and neutral line that goes to a load, your load can be lamp for example. In the middle, you usually have a switch.
With the sonoff, you cut that connection…
And you place the sonoff in the middle. The sonoff acts as a switch that is controlled via Wifi.
Note: if you have a earth line, it has to go outside the sonoff.
Before proceeding with this project, I want to let you know that you’re dealing with mains voltage. Please read the safety warning below carefully.
Let’s hook up the Sonoff. On the left side, you connect the active and neutral accordingly to the pinout. Active and neutral come out on the right.
Installing the App
Now you have everything in place to install the app to control the light with your smartphone, follow these next instructions:
- Search for the app eWeLink app and install it
- Open the app and create an account
- Power up the Sonoff device and connect the appliance that you want to control (in my case, it’s a desktop lamp)
- Press and hold the Sonoff button for 5 seconds, so the LED green starts blinking
- Go to the app and press the next button
- Enter your network credentials and choose a name for your device
- Add it to your dashboard.
Refresh the dashboard and you should see your device. Press the on button to turn it on. Now the lamp is On. and if you turn off. The lamps goes off.
Watch the video to see a live demo of the Sonoff device.
Keep in mind that with this app you can control any device on and off from anywhere in the world, because it’s controlled through the eWeLink cloud servers.
The app also comes with a nice set of features, click the timer button. You can add a timer that can be activated on a certain date and time.
I’ve tested this feature and it has been working flawlessly.
Sonoff tutorials list:
That’s it for now, I hope you had fun learning about the Sonoff device. Make sure you subscribe to my blog, because I’ll be posting more tutorials about the Sonoff. I’ll be showing how to flash custom firmware.
Do you have any questions? Leave a comment down below!
Thanks for reading,