Sonoff WIFI smart switch - uses ESP8266

Posted on
Fri Oct 07, 2016 6:22 am
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Sonoff WIFI smart switch - uses ESP8266

I ran across this and thought I'd share. It's an inline mains-level relay controlled by an ESP8266. Best of all, it's pre-built/packaged and less than $5.00 USD each! By default it communicates with "the cloud" but it's very easy to load your own Arduino sketch on, the examples below have it doing pub/sub with MQTT. Here's the device, there are several versions available on the website, including ones with temp/humidity, or dual relays, this is a photo and link to the single relay:
Unknown.jpeg
Unknown.jpeg (30.94 KiB) Viewed 8486 times
https://www.itead.cc/sonoff-wifi-wireless-switch.html

Here is the original youtube video I ran across describing, and hacking it:
https://youtu.be/_389pQPLyr8

And here is the youtube guy's website with more info and links to the source he used in the video:
http://www.superhouse.tv/17-home-automation-control-with-sonoff-arduino-openhab-and-mqtt/

I've ordered a couple to play with and will add to this thread when they come in. Interestingly, the ones I ordered mention MQTT in the description, but I don't know if they're already enabled, or just can be, with the alternative firmware loaded. We'll see when they arrive. Happy hacking!

Terry

Posted on
Fri Oct 07, 2016 11:20 pm
mclass offline
Posts: 312
Joined: May 13, 2015
Location: Melbourne, Australia

Sonoff WIFI smart switch - uses ESP8266

But wait ..... there's also the touch switch :

https://www.itead.cc/smart-home/sonoff-touch.html

If the API is "discovered" and/or someone clever comes up with a plug in - how good would that be!!

Or could these work with the fabulous Arduino plug in??


Sent from my iPad using Tapatalk

Posted on
Sat Oct 08, 2016 5:55 am
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Re: Sonoff WIFI smart switch - uses ESP8266

I saw that, I almost ordered one but decided to wait. It uses the ESP8266 as well so it should be just as easy to modify. I didn't get it because there is no dimming capability and we use that pretty heavily in my house.


Sent from my iPhone using Tapatalk

Posted on
Sun Oct 16, 2016 7:09 pm
elf55 offline
Posts: 45
Joined: Mar 19, 2012

Re: Sonoff WIFI smart switch - uses ESP8266

No mention of UL, CSA, or FCC approvals. This is just for playing. Wouldn't recommend installing it in a home. At least not if you ever want to make an insurance claim for a fire.

Posted on
Tue Feb 28, 2017 11:02 am
LulaNord offline
Posts: 1
Joined: Feb 28, 2017

Re: Sonoff WIFI smart switch - uses ESP8266

Hi...i am a new user here. As per my knowledge there are a variety of development environments that can be used to program the ESP8266. The ESP8266 community created an add-on for the Arduino IDE that allows you to program the ESP8266 using the Arduino IDE and its programming language.

turnkey assembly
Last edited by LulaNord on Mon Mar 13, 2017 4:00 pm, edited 1 time in total.

Posted on
Mon Mar 06, 2017 1:17 pm
roussell offline
User avatar
Posts: 1108
Joined: Aug 18, 2008
Location: Alabama

Re: Sonoff WIFI smart switch - uses ESP8266

I see that Sonoff has a cool environmental sensor now - probably gonna have to get one of these. If it's as hackable as the switches, it will be easy to integrate with Indigo. Oh yeh, and it's only $20!

https://www.itead.cc/smart-home/sonoff-sc.html

Unknown.jpeg
Unknown.jpeg (12.06 KiB) Viewed 7962 times


Terry

Posted on
Sun Mar 12, 2017 4:47 pm
mclass offline
Posts: 312
Joined: May 13, 2015
Location: Melbourne, Australia

Re: Sonoff WIFI smart switch - uses ESP8266

Pleased to report that my Sonoffs have arrived, and have been flashed and integrated into Indigo using Karl's excellent Arduino plug in.

Apart from not having any certifications (see elf55's previous post), these low cost devices have great potential. I am also investigating the use of the Sonoff SV (safe voltage) devices as part of my sprinkler system.

However to be really utilitarian, the next step is to figure out mods to the sketch to:
- Use the LED to indicate progress of the connection to wifi (eg flash until connection succeeds)
- Use the push button to provide local (manual) control of the Sonoff in the event of wifi and/or Indigo being unavailable
- Use the LED to indicate status of the relay (on/off)

Any assistance/advice in achieving these mods would be appreciated!

Mclass


Sent from my iPad using Tapatalk

Posted on
Sun Mar 12, 2017 10:03 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Sonoff WIFI smart switch - uses ESP8266

could you post your current sketch..
and also what are the functions available in the device.. = how are they connected to the ESP? for input and output ..

Karl

Posted on
Mon Mar 13, 2017 6:15 am
mclass offline
Posts: 312
Joined: May 13, 2015
Location: Melbourne, Australia

Re: Sonoff WIFI smart switch - uses ESP8266

Hi Karl!

I'm currently using the latest version of your standard sketch, configured for an ESP16, and this works "out of the box"!

The Sonoff is documented in various places as being "hardwired" as follows:

- relay: D12 - GPIO12 (high to turn on)
- LED: D13 - GPIO13 (low to turn on)
- push button: D15- GPIO0 (low when switch is pressed)

I have verified that relay & LED can be operated from your plugin, but unable to verify the button - the plugin does not permit the use of D15? May need some further investigation.

I understand that other pins may be available (with varying degrees of difficulty?) including the analog pin.

If you're really keen, I'd be happy to send you a Sonoff (with flash headers already installed) so you can try one out - they're about $A12 each


Sent from my iPad using Tapatalk

Posted on
Mon Mar 13, 2017 7:14 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Sonoff WIFI smart switch - uses ESP8266

I never got anything from down under in the mail. That would be cool.

As for the d15 .. there are different mappings for the ESP. I need to check the code if that is blocked.
I could just remove the ignore pin line.


Sent from my iPhone using Tapatalk

Posted on
Mon Mar 13, 2017 5:25 pm
mclass offline
Posts: 312
Joined: May 13, 2015
Location: Melbourne, Australia

Re: Sonoff WIFI smart switch - uses ESP8266

Thanks, Karl! I note you've issued a revised sketch addressing the button pin, so will give it a whirl when (if) I get time. It was a holiday weekend just gone that gave me a little spare time to play.

Happy to send you a "reward" for your great work - PM me your postal address and I'll oblige. Pretty circuitous route for a Sonoff from China, eh??


Sent from my iPad using Tapatalk

Posted on
Sun Mar 19, 2017 7:13 pm
mclass offline
Posts: 312
Joined: May 13, 2015
Location: Melbourne, Australia

Sonoff WIFI smart switch - uses ESP8266

Thanks, Karl - your new version of the Arduino plugin and sketch now allows accessing the push button on the Sonoff (D0).
I guess I now need to brush up on my Arduino "sketching" to add push button operation to the section "do my stuff". Any hints appreciated.
BTW, Karl, that Sonoff's still available if you want to have a go!!


Sent from my iPad using Tapatalk

Posted on
Thu Jun 14, 2018 11:13 pm
anothersphere offline
Posts: 158
Joined: Jul 01, 2009

Re: Sonoff WIFI smart switch - uses ESP8266

These things seem very cool. I have some usage for them in outside areas (obviously in an IP rated box) to do stuff like turn on lighting/pumps etc, where blowing up/bursting into flames is not going to smoke my house.

Google found me this: http://supersimo88.altervista.org/hacki ... utomotion/ which I am keen to try as it seems to be a nice way to move forward to what looks like a UI served by the device. Now if we can curl the URL's off that GUI then that opens up some simple Indigo functionality. When I get home I am going to surf to dx.com to get me some bits and pieces to experiment to see if I can make this happen. It needs a USB adapter, header pins and a soldering iron to flash it - should be easy once one is done. I am hoping I can get the low voltage Sonoff module to flash the same way coz that is very interesting to me for some low voltage needs I have.

Has anyone already tried this? I will post my progress.

Martin Miller

Auckland - New Zealand

Posted on
Fri Jun 15, 2018 1:37 am
racarter offline
User avatar
Posts: 468
Joined: Jun 18, 2016
Location: North Yorkshire, UK

Re: Sonoff WIFI smart switch - uses ESP8266

I have a couple of these, and the 4-channel low voltage device too. I flashed them with ESP Easy firmware then added code to a xAP plugin I wrote, to handle the UDP comms on the Indigo side. This requires some configuration on the ESP side to send data in the required format, but once that's done they work well and seem stable. The only downside if you have a lot of them is that they each take up an IP address on your network.

I found a slight issue with the 4-channel device after flashing; when you power it up the relays all fire for half a second or so, so if you had a power cut the connected devices would switch on briefly when the power was restored. The single-channel devices don't exhibit this behaviour.

This was my starting point: http://www.instructables.com/id/Control-Sonoff-From-Raspberry-Pi/

Posted on
Fri Jun 15, 2018 4:59 am
mclass offline
Posts: 312
Joined: May 13, 2015
Location: Melbourne, Australia

Re: Sonoff WIFI smart switch - uses ESP8266

I used Karl’s Arduino plugin with great success. Check out earlier posts in this thread for details!


Sent from my iPhone using Tapatalk

Who is online

Users browsing this forum: No registered users and 1 guest