Random Nerd Tutorials
Shares

Sonoff – $5 WiFi Wireless Smart Switch Introduction

Shares

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


Here’s the basic Sonoff. You can get a Sonoff for $5 on eBay: http://ebay.to/2eNzHf2.

sonoff_pic

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

sonoff-highlighted

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.

Sonoff Example

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.

slide2

With the sonoff, you cut that connection…

slide3

And you place the sonoff in the middle. The sonoff acts as a switch that is controlled via Wifi. slide4

Note: if you have a earth line, it has to go outside the sonoff.

slide5

Safety warning

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. 

warning-m

Sonoff usage

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.

sonoff_circuit

Installing the App

Now you have everything in place to install the app to control the light with your smartphone, follow these next instructions:

  1. Search for the app eWeLink app and install it
  2. Open the app and create an account
  3. Power up the Sonoff device and connect the appliance that you want to control (in my case, it’s a desktop lamp)
  4. Press and hold the Sonoff button for 5 seconds, so the LED green starts blinking
  5. Go to the app and press the next button
  6. Enter your network credentials and choose a name for your device
  7. 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.

on-and-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.

timer

 

Sonoff tutorials list:

Wrapping up

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,

Rui

Recommended Resources

Home Automation using ESP8266 »
Build IoT projects and home automation gadgets with the ESP8266 Wi-Fi module.

Build a Home Automation System »
Learn how to build a automation system using open-source hardware and software from scratch.

Arduino Step-by-Step Projects »
Build 25 cool Arduino projects with our couse even with no prior experience!

Leave a Comment:

Add Your Reply

⏰ Early Black Friday 2017 Special ⏰
Download all our courses up to 35% off