More from Sonoff

Sonoff Mains PlugToday I got a couple of new(ish) gadgets from Sonoff – one being a UK version of their WIFI mains adaptor. So the point of this if you don’t know Sonoff is that their stuff is solid and inexpensive – not two words you normally find in the same sentence. The mains adaptor is absolutely solid – and when it powers on it has a nice coloured ring light to let you know it is working.  Sonoff have their own software for this but as it is ESP8266-based I usually put my own in or use Arendst’s Sonoff-MQTT-OTA-Arduino software – which up to now is proving reliable and has one advantage over my own – it is smaller and fits into the Sonoff devices without replacing the FLASH (well, it has two advantages – it supports the Amazon Echo – but as I use HA-Bridge to do that, the subject is moot).

So – I opened the unit up and Sonoff have even now kindly put labelling on the 4-hole connector inside for programming – very nice of them.

What can I say, Sonoff SCit worked first time, I can fire off MQTT commands to turn the thing on and off and can override that with the button on the front. Most other similar products I’ve seen are either proprietary, expensive or generally naff – this is GOOD and no secrets – you can get diagrams, change software and it works well.  Like the other Sonoff mains control boxes, good product – good price ($12.86 plus whatever post to get to your location – but even then – compare that to B&Q rip-offs). Lovely.

And with that, I’ll move onto the Sonoff SC – the unit you see on the right. No it is not a loudspeaker. To quote the company - Sonoff SC is an ESP8266 based WiFi environmental monitor device. It detects current temperature, humidity, light intensity, air quality, and even sound levels, and directly send realtime data to iOS/Android APP EWeLink

Sonoff SCAnd yes, I believe there is some source out there but this one is likely to be a little more difficult to DIY as it contains both an ESP8266 and an Atmel 328 – no doubt for two things that need A/D where the ESP8266 has only one analog input. So this gadget contains a SHARP Dust sensor, a DHT11 (I know, the crappy one) temperature and humidity sensor, a light sensor (a simple ORP-12) and a microphone – so it is a test-everything unit.  It runs off 5v.

So we ran it up this afternoon – there’s a nice phone app and it only takes 5 minutes to setup – I’m trying to think where you would use this – maybe in an old-folks home you were running just to keep an eye on everything?

Sonoff SCFor me it fails in that there’s no MQTT connection so unless you use their App the use is limited but they DO claim it is “hacker friendly” so when someone goes to the bother of making a complete replacement software – with MQTT and the option to replace the hated DHT-11 with a marginally more expensive DHT-22 – I may just take more of an interest.

Sonoff SCThe thing is you have light sensing in the range of “dusky, normal and bright” – I’m not sure what use that is – had they made this more than $19 they could have used one of those little light sensors that gives exact LUX out for visible and also measures humidity and temperature accurately.

As it is they’ve used an ORP-12 device which is a bit basic.  Still – if I made a super-duper one and had a 3d printed case made, it would look like something out of Dr Who so hats off to them for making this at a price in a sensible case. It is almost worth getting one for the case to then gut it and do your own thing! Recently in the blog we’ve covered all of these sensor scenarios except for the dust sensing and there’s plenty of doc on that.  Worth a second glance.

Depending on the device you are using you can click on any of these images to get larger ones.

Update 12/JAN/2017:  Reader Jayhttp://tinkerman.cat/sonoff-sc-with-mqtt-and-domoticz-support/ pointed me to this link which gives the oppotunity to replace the lacklustre DHT11 with a DHT22 on the Sonoff SC and to upgrade the software - nicely written article.  And secondly - just to say I now have three of the mains UK sockets in full time use and not a hitch - they work perfectly using this software (latest version as of a couple of weeks ago - but note at the time of writing he's just today updated the software again).

Facebooktwittergoogle_pluspinterestlinkedin

43 thoughts on “More from Sonoff

  1. Looking at the software for the SC that is on the wiki, the esp runs the standard AT firmware while the 328 does all of the lifting with the sensors.

    1. We kind of figured that would be the case.. I must admit - if no-one comes out with full pack of software I'm inclined to gut it, put a proper light sensor (UV/IR/Visible), a BME280 and a gas sensor on an ESP - and MQTT to it - thing is - it will look good in the living room! Wife-Friendly.

  2. Re sonoff U.K. Wifi socket .. I wondered why they put the push below the socket so it gets obscured by the flex from the plug, however I found it's relatively simple to pull off the retaining collar and twist the socket round while you have the guts out soldering the connection pins to the board, so the push button is now at the top .. much better I think.

  3. A real shame most China manufacturers claim EU socket when they really are DE/NL, so these don't even fit the sockets I have 🙁

    Would also be nice if they could include the RF receiver, so you can have a 'traditional' remote socket with wifi for automation

  4. Hi Pete,

    Can you program the sonoff devices without open them ?
    From factory the software act as AP. Is it possible to connect to that AP and upload your sketch ?
    Now I open the case, put GPIO- to GND, connect the FTDI and upload the sketch for the fist time.

      1. Just received the socket version. There are no fixing screws and I have tried to prise apart the 2 halves. It seems to be factory sealed.... do I need to be more brutal?

  5. When "dusky", turn on Sonoff to light the LED : ) The Sonoff SC is designed for the IFTTT for the Sonoff , S20 socket, Sonoff Hum and other device. And you can do this in eWelink app , or you can hack it with you code, make it join your own smart home system as a sensor center.

    We will change the DHT11 to DHT22 in next version...

    1. Thanks for updating us Freezing. DHT22 much preferable. Have you published anywhere the protocol used between the asp ESP and uino?

  6. How can the dust sensor access the dusty air? According to the photo, there is this membrane on the top. Would it need a small fan to measure the room air?

    1. There is no membrane on the top - there is a metal grill that lets air through freely. There is only the smallest slot at the bottom - I think I'd like to see more slots at the bottom as a minimum.

  7. I have just ordered one of these.. Would be awesome if the DHT22 upgrade made it into my unit (but I doubt I will get that lucky!)

    I am looking forward to hacking it. A few things to note:

    The Sonoff has an SD card attached to the Atmega, but if you look in the arduino firmware for the sonoff, the SD card is not being used at all! It seems to be connected to the correct ports of the atMega, so it should be trivial to add logging functionality to the device.

    Not all the Atmega ports are used up in the schematic. D3, D4, D5, A0, A4 and A5 are unconnected. Should be easy enough to add data to these pins. With A4 and A5 being free it should be easy to add i2c devices to the unit. I am thinking about adding a piezo speaker for audio feedback. Its a shame that these were not broken out already (perhaps an idea for the updated version?)

    D7 is attached to a 2N7002 transistor (120mA) and the output of this is broken out to an unused header marked LED, Should be easy to add multiple LEDs to this (although I am considering an addressible light ring) to make a night light or visual notifier (assuming that the plastic is thin enough to transmit light).

    The 2N7002 transistor has enough power to drive a 0.12A 5v micro fan. I am thinking that I might be able to add one to generate some airflow through the device during/before readings. Other environmental sensors that I have seen have some sort of forced airflow. Indeed in the itead documentation, the base looks like it has some sort of fan in there....

    There is a single pin broken out on the ESP chip, though the RX and TX pins have headers that could be used. Currently AT commands are exchanged between the ESP and the Atmega... Using a serial/mqtt bridge and if you accepted one way communication from the arduino to the ESP, there is another port there for the controlling of.

    This could be a great little platform for HA purposes and at a pretty reasonable price.

    1. If there is software out there to do the job - i.e. upgrade, then I have no doubt it will support DHT22 - if not - maybe Sonoff will offer any upgrade to existing users - ASK THEM TO. For monitoring my own view would be to do storage on a central controller like a Pi rather than messing around with an SD - that way you could get web stats online.

      Serial LED is a good idea - but it depends what load is on each device- for example, I have found that on the ESP8266, I2c and Serial LED are great - but not at the same time. I can't imagine why they are still using that old-fashioned AT command set - there are far better ways to have ESPs and Arduinos communicate these days.

      Regardless, yes, it's a starting point for a really nice addition to the toolbox.

  8. Hi there. Peter. Love your blog.

    Was wondering if you could help me. I have a Sonoff POW that I soldered a header to the serial pins and connected my FTDI programmer as usual.

    Unfortunately, I had my FTDI adapter set to 5v incorrectly and, of course, nothing happened. When I set it back to 3.3v I find that the board is never detected and all of the uploads fail (with the usual espcomm_sync failed error).

    I have a few more sonoffs and I'm able to program them correctly. It's just this one that I'm having problems.

    Did I brick it by attempting to flash in 5v mode?

    PS: one interesting fact is that the sonoff pow still works! I hooked it up and its working with the original firmware (need to use the ewelink app though)... I just can't program it.

    1. It could be that it is damaged due to the 5v. All over the web you will see warnings about this - I have used 5v inputs (NOT recommended) on ESP8266 many times without damage - but I do remember putting 5v on one of them as power once - fried.

  9. Hi Peter, I ran across this recently and it would be a nice option for those wanting a simple ON/OFF capability with any ESP12 based module. It emulates the Wemo switch modules. I programmed this into one of my spare Sonoff S20 modules and it worked just by plugging it in. I do have a Wemo bridge for the LED lighting so that probably provided the WiFi credentials but it does have a webpage setup included for setup.

    https://www.hackster.io/kuzma/alexa-voice-control-lights-with-nodemcu-1bddb4

    1. Hi Dave

      So - a few comments:

      1. This code is probably useful because it is simple enough for us to understand how the Alexa interfacing works.
      2. If you want to have that feature in your software, a WAY better solution is this one - https://github.com/arendst/Sonoff-MQTT-OTA - because he's written this for the Sonoffs - i.e. ESP8266 but with multiple access point fallover etc and multi-purpose input buttons. I'm using it for simple Sonoff-type projects instead of my own more comprehensive code (which doesnt' support Sonoff directly but read on).
      3. There is no need to have Alexa capability in the boards if you're using a central controller like a Pi or similar because HA-Bridge does exactly the same, simulating lots of WEMO devices.
      4. None of these solutions has any means to CONFIRM that the action has taken place - hence the skill we put together.

  10. Peter, thanks for this, and your blog in general.. I keep coming across your name associated with almost everything I want/try to do ref home auto, Node-red, esp8266, etc.
    As a result of the above plus the many other resources it links, I now have 2 sonoff devices controlled from both MQTT (node-red managing), plus from Alexa running a custom skill, plus from Alexa using wemo 🙂
    Happy 2017!

  11. Pete,

    Been reading for some weeks and learning much as a noob.

    Didn't find mention of ESPurna on your site, a library based firmware for ESP8266, emulating WeMo and many Sonoff / other device support in latest v1.4.0:

    http://tinkerman.cat/emulate-wemo-device-esp8266/#more-1329

    https://bitbucket.org/xoseperez/espurna

    How would you compare it with your stuff or the Arendst MQTT- Arduino software you highlighted?

    Can ESPurna functionality be integrated in your Script somehow ?

    1. Given the effectiveness of the Arendst software which is mainly oriented toward Sonoff and similar, I don't plan to integrate Alexa capability into my software which is way more general purpose. About to pen an article on some new work on sequencing RGB LEDs soon - integrated into my software, ideal for presentation displays.

  12. Hi Peter,

    Thanks for your blog.

    I'm trying to flash the Slampher with an arduino sketch which i've previously done with the original sonoff and i'm getting this error.

    i'm trying to hack the Slampher sonoff. I've already done the regular sonoff, and tried the same method with the Slampher but getting these errors:

    Global variables use 33,408 bytes (40%) of dynamic memory, leaving 48,512 bytes for local variables. Maximum is 81,920 bytes.
    warning: espcomm_sync failed
    error: espcomm_open failed
    error: espcomm_upload_mem failed

    It worked fine with the original sonoff and assumed the pins are the same on the Slampher? Theres a little white arrow on one of the pin-out's which i'm assuming is 3.3v then from there it would be RX, TX and GND?

    1. Ok, so I just found your post on the slampher - needed to change the R21 resistor to R20... doh!

      My eyes aren't what they used to be so out with the helping hands and magnifying glass!!!

      Hopefully me trying to do this without the resistor change wouldn't of damaged anything?

    2. Why not ask over a the relevant Arduino github. It LOOKS simply like you've not put the unit into programming mode. Communications failure. When you say "Assume" the power and ground leads - not a good idea - check with a meter - in the blog http://tech.scargill.net/slampher-unfolded/ I show the 3v3 line and ground lines you can check. If that is correct you only have two options for RX/TX and up to now I've not damaged any units getting THOSE the wrong way around.

      1. Thanks Peter. It was the resistor. I've successfully flashed it with my code now and can now control it via mqtt. Now to get my accessory file code sorted so I can use it with HAP-NodeJS/homekit and siri.

  13. Hi there,

    at first I have to admit that I didn't read the whole post and the comments .... so please forgive me if the answer is already within your comments!

    I'm looking for a brightness sensor (giving a numerical value for the brightness, maybe in lux or somthing else) to be used along with the Sonoff-devices (maybe the Sonoff TH) which is supported by the firmware written by Theo Arends on github.

    Would be glad if someone can help me out.

    Regards
    Joe

  14. Hi
    I have been looking at the "Sonoff-TH-Temperature-Humidity-Monitoring" on ebay. I would like to remotely monitor the temperature of my fish tank from a web connection from my phone. I don't like the fact that you have to connect to a web server in the cloud. ( Not secure ) Can I directly access the temperature unit ?
    Thanks
    Bob

  15. Someone (Sam) in the orignal Sonoff blog was asking about integrating Sonoff with existing light switches. Well you could detect the switch somehow and tell Node-Red, but my son and I have independently developed solutions. My son, in Australia, has replaced the Clipsal light switch with a push button that connects to the Sonoff button. Easy to do due to the modular Clipsal system and the voids in the wall.
    I chose a different route in the UK. I modified the Sonoff by breaking the neutral link (top and bottom of the board) and using the old output neutral connector (suitably labelled) as input to a simple mains voltage detector connected GPIO14. The light switch(es) connect to the voltage detector and the lights are then controlled by the Sonoff. My modified Pete Scargill code can use this in either a) two way switch mode (wall switch change, on or off, will toggle the output) or b) obey the wall switch mode (wall switch setting will be honoured when it changes).

    Both of these solutions avoid any other infrastructure, such as WiFi and Node-Red, so reduce the points of failure, which I consider a good thing, but can still be controlled using MQTT.

    Pete

  16. At time of arrival it seemed that the S20 mains switch was not always switching on when I put it in the wall outlet. At the time I didn't have enough time to investigate and when I tried later it seemed to work again. Then again it stopped working when I removed and re-inserted it into another wall outlet.

    It seems that the device only boots after it has not been used for a while. If it works, then it works, but when I remove it from the power outlet it stops working when I re-insert it. Only after a few days of waiting I can use it again.

    First I thought it was the firmware, but after flashing Espruino on it and writing my own code, it turned out it must be something with the hardware. With my FTDI programmer connected my code runs always as expected when applying power, but not when it is powered from mains. The only way to get it working again is to wait a few days and then use it.

    Anyone has an idea what could be causing this?

Leave a Reply

Your email address will not be published. Required fields are marked *