Itead Slampher and Sonoff

Slampher - in Scargill's review of Slampher and SonoffRemind you of IKEA? No? Heard of ESP8266? Yes? Well, Slampher and Sonoff are two products from Itead and I think you’ll like at least one of them. They arrived at my desk today. Slampher is a screwfit lamp fitting – take the E27 lamp out – put Slampher in – screw the lamp back in and you’re in business with a remote controlled lamp. It really is that easy.

This blog updated May 10, 2016.

There’s a tiny button on the unit that you press to turn the lamp on or off manually if you ever need to – or hold it down and you can make it listen for a controller – the handy – and i have to say very nice quality – keychain controller which can control 4 devices.

Handset - in Scargill's review of Slampher and SonoffThe REALLY good thing is that both of these products use ESP8266 so if you want to go in and re-program them – as I have  – to handle MQTTon your WIFI!!!! You CAN do but there is an APP if you don’t want to do it the hard way. I don’t have the App at this time so I can’t comment… but it’s an ESP8266 – how hard can it be to get that right.

Slampher and SonoffThe other product is called Sonoff and it’s just a little box that you wire mains into – and out the other end you fasten it to whatever you want – and control it the same way. SO the units obviously have both WIFI (ESP) and a 433Mhz receiver – because the little handset is 433Mhz.  Sonoff would not look out of place on a skirting board at all (proper little screw connectors inside – no soldering needed).

These are NOT expensive – in fact that really IS the point – Sonoff in particular – I could not build one at that price – and I guess that is part of the charm.  I can make this stuff with my eyes shut but by the time I put it all together and in a box….

The units I have are solid looking – the little mains controller Sonoff – the PCB inside is well put together with proper isolation on the PCB (some of you will have seen some HORRIBLY DANGEROUS pcbs in the past when it comes to UK mains but little Sonoff is ok at least at first glance).  I’ve not had a chance to pull the lamp unit apart yet – that will come later.

Pricing: I found this – $4.85 – if you live in the UK the postage brings it to $9.37 but even then! I checked out the cost of 3 – $14.55 all in to UK that is $5 each – that’s around £3 or so.

https://www.itead.cc/sonoff-wifi-wireless-switch.html

DIY programming: You’ll like this if you know how to program ESP8266 chips. I now have a diagram for Sonoff – initially the connectors did not seem to match those on the diagram – so I contacted Itead – they were keen to point out that they have a cloud system and App and of course the remote control via radio – all of which I’ll lose when I reprogram the board – but hey…. I want to control these with MY kit.

Look at the diagram below… this is looking at the TOP of the board. There is a 4 way or 5 way connector. If the latter you might want to get the meter out – but on the 4-way (mine)….  the SQUARE pin is not as you might think ground – it is 3v3 – then we have serial, serial and ground. If you wire your FTDI as per the wiring diagram below it should work.  The relay is controlled by GPIO12.

I was happy to see cooperation from Itead – obviously they would prefer that you use their cloud software and most will – but we are hackers and would never be satisfied without control, right? Ignore the LED, it is fastened to the RF device so you don’t have control over that. Right now I don’t have enough info to make any use of the RF device. If someone knows better please write in. Would be nice to have both.

Warning – you are on your own if you start this – you will need your own software and messing with the board will kill any warranty.  Clearly this must NOT be plugged into the mains while programming – use FTDI at 3v3 settings. No doubt 5v would cause damage.

 

Sonoff board

 

Image635909899921896626

CLARIFICATION – the square pin is NOT ground – the square hole is 3v3. You should see that the round hole is connected to the flood filling (if you have good eyesight).

Use FTDI at 3v3 setting – in the original boards,  press the large button –THEN power up FTDI. DO NOT connect mains power while doing this – you will fry. Test MQTT connectivity, disconnect, put back in the box, use. NOTE – the newer boards marked RF do not seem to attach GPIO0 to the button – see later blog – it may be necessary to make a VERY find short at power=up – of two surface mount components.

As for actual use.. here’s the interface in Node-Red

tmp427F

Complicated, isn’t it. The node on the left is one of Andrei’s UI components – the node on the right is the standard MQTT connection – all of course running on my Raspberry Pi2 and already in charge of the heating and a load of experiments.

Here’s what it looks like on the phone…

tmpEE3C

and here it is - waiting for the screws which for the LIFE of me I can’t find… works a TREAT. The output relay is on GPIO12.

tmp66FB

I have modified my general purpose MQTT software to run with the Sonoff devices and it works a treat.  https://bitbucket.org/scargill/esp-mqtt-dev   - see the home control 2016 project in here where you’ll also find binary files.  A couple of settings need changing from normal – I normally use GPIO2 for WIFI setup and the SONOFF WIFI units use GPIO0…  also  - GPIO13 which I use as a status indicator – turns out the Sonoffs use them but reference 3v3 so I have an inversion setting so they flash off most of the time instead of on all the time – it’s all in the DOC file in the project above. With both of those settings updated... you can also use the button as an on-off button if you like (toggle).

The SONOFFs have only 1MByte of FLASH which would kill off OTA for all but the simplest of projects – my code needs the larger size IF you want OTA. With this in mind, is it worth paying extra for the Electrodragon? Some say the quality of the latter is not so good? But they do use an ESP-12 which will have the normal 4Mbytes of FLASH… what do you think. Update Jly 2016:  The Electrodragons didn't turn out so well - but now I've just proven that it is in face easy with a fine soldering iron to fit a £0.37 32Mbit FLASH chip to these, replacing the original - which means full OTA and no problems expanding.  See http://tech.scargill.net/32mb-esp01/ for more info.

 

Facebooktwittergoogle_pluspinterestlinkedin

292 thoughts on “Itead Slampher and Sonoff

  1. Pete,

    You've peeked inside the Sonoff, so what's the supply to the internal electronics? Is it
    capacitor and dropper resistor, or a proper PCB-mounted transformer (ala Hackitt)?

    1. Hang on.... I'll rip it apart again. Ok so first things first and apologies for the technically challenged 🙂 There's a MOV on the input... then a small bridge rectifier - one side - the Neutral goes straight through to the other side and they've deliberately over-soldered that and another track for current...air gaps where necessary. After the Bridge a smoothing cap and some kind of triac or Mosfet arrangement. Little high-frequency transformer... on the low voltage side, not a lot... esp8266 chip - FLASH chip - and a tiny chip for 433 meg radio.

      1. Hello

        I just bought the sonoff with RF. I can't teach it my Nexa RF controller.... Does it only work with RF controller?

      2. Ho, I was wondering if you knew if there was a way to put the sonoff in flash mode without the push button. I have ended up breaking one of my sonoffs and it would be a shame to waste it as I'm sure the rest works fine. I need to touch gpio 0 to ground. Is that right?
        Kind regards

  2. Interesting. Sounds like it could be something along the lines of the ON-Semi line of integrated switchers (except that their package looks more like an opto-isolator than a MOSFET). Anyway, sounds like a real, isolated PSU (which surprises me even more, given the price).
    Thanks for ripping it apart again. Definitely sounds like a worthwhile investment.

        1. No Fuses inside, just the 433Mhz Radio, ESP Chip, Relay (And Driver), Memory for ESP and a switcher buck regulator for powersupply, they already have and sell seperate mini PSU Switcher modules so they probably just included it on the PCB for ease. The Switch would provide plenty of isolation based on the length of the plastic stem... you never get near the mains (When the covers are on that is)

          1. I just need to figure out exactly what the RF is doing and why they have data lines going to the RF chip - and I can add that to the code. I've now had one running MQTT for 2 days on dawn/midnight and with my playing with the thing remotely - not a hitch. Just about got the OTA software running so I won't even have to take them off the wall when I discover the next fatal flaw in my software 🙂

    1. That link also shows internal pics for those interested.

      I'd buy it myself if only it passed earth through, but it's just live & neutral.

        1. No, you wouldn't want to switch earth - just passed through as I said, for those appliances that need it.

    2. There are a few (At least 2) different kinds, one that is currently on their site is an MQTT WIFI version with no 433Mhz Radio and I think only 5Amp rated, could you have seen that one ??

  3. Thank you for the info. For $10 USD I'll give it a try. It's good to see 8266 in devices and still have costs down. I would like to take this as a sign of things to come. 8266 with MQTT will be cheaper than my Z-Wave.

    1. Excellent - good luck. I've had so much in the way of reliability out of Mosquitto that I have no intention now of messing around with anything that does NOT support MQTT 🙂

      1. I was issued a refund today for the Indiegogo purchase with no reason listed why. I was kinda bummed but did notice that I could get one without remote even cheaper from their site at ahttps://www.itead.cc/sonoff-wifi-wireless-switch.html

        Any idea why the cancelled the Indiegogo and if they are really shipping from itead?

          1. Wound up ordering three from the main site for less than double of the original. Missing 433 controller option but I don't need that. Blessing is disguise? I hope there will be more products like this coming out.

    1. Well yes, I've not ripped Stampher apart yet but if Sonoff is easily re-programmed for MQTT then I can see a lot of them in my future, not that I can't build the same thing - but they are small, neat and convenient.

  4. Looks good apart from one thing. Judging by what buttons are/aren't on that remote control key fob, it looks like the device uses a single RF code for both on and off - i.e. it simply toggles the status each time it receives a command from the remote. Is that correct?

    1. Yes it toggles on and off.. not ideal - but that is the 433Mhz part of it. For me the reason I like these is that they are ESP - and of course then you can do what you like. Must find out which port bit they use to turn things on and off... and where we can get access for FTDI programming.

  5. ALL: See updates to blog. I now know that GPIO12 is used in Sonoff to control the relay, ITead have released a diagram but the connections I see on the board do not seem to match the connector available on the diagram - I've asked for clarification. I've now sorted access to ground, in, out and 3v3 - just need gpio0 for programming.

        1. What would be awesome, If we could add to their cloud services and use their IOS/Android app, this would be the Raspberry Pi of IoT devices.

    1. Sadly I put the magnifier on the radio chip and came up blank - it would have been nice to be able to continue to use th 433mhz radio fob.. but then - as my plan is to use MQTT - what would be even better would be a WIFI fob that sends MQTT and just let Node-Red handle the lot 🙂

  6. Nice.

    Sonoff is very similar to those Banggood 8266 relay boxes which Rob Fowler linked to on your Facebook page.

    I bought three of those and downloaded my own code onto them with OTA update capability and hooked them up to Node Red. Very easy to do 🙂

    I prefer the Sonoff boxes though as they've got a tidier mains in/out connection solution. I wonder what flash size they have on board ? The banggod boxes had 1Mbyte (which is the minimum for OTA updates using the Arduino IDE approach).

    1. I THINK the Sonoff is the successor to those boxes. I'm hoping they have more as my OTA code needs it. Right now I'm not running OTA on these but as you have to take 4 screws out to remove the module, OTA would make updates less tiresome.

      1. The boxes really are nice - I just wish they'd put the LED on the ESP and not the radio module. I use GPIO13 as an indicator to say that the board is connected to WIFI and I don't THINK they've actually brought it out from the chip.

        1. According to the schematics the LED used is a two color LED; one lead (red) connected to GPIO12 together with the relais; the other lead (green) is connected to GPIO13. The red LED is also connected to the 433MHz microcontroller. When I receive my order I will verify.

          1. Finally received three sonoffs. The devices look exactly as currently shown on the ithead website so without the 433MHz hardware (as advertised). The logic for the red LED is not present (Q4 and R23 are missing) so that won't work without a hardware fix. I uploaded my own MQTT software to the sonoff and am able to control the green LED by GPIO13. So I'm pleased with the cheap hardware! The flash used is 1Mb which allows me to use my OTA implementation succesfully.

            1. Your OTA implementation... I'm using OTA (c) but mine has one issue I need to resolve. It will not handle external addresses for the OTA - so "192.168.0.100" works a treat... but any external address fails - and of course you're not able always even to have a fixed IP for an external address. I'd like to keep the latest OTA on my service provider site at tech.scargill.net - do you have a routine to resolve that?

      2. Yeah, Rob's original link now goes to the Sonoff module on Banggood (and the same review comment is listed against Sonoff, which is a bit naughty!).

        I've ordered a couple to have a play with. The original Banggood units looked like they had exposed a spare GPIO pin to an unused PCB pad which, with some careful soldering, could be used.

    2. The " Banggood 8266 relay boxes " was made by ITEAD as well, an older version.
      It was DISCONTINUED for the difficult in volume production.
      Peter's right, Sonoff is the successor version.

      1. I already did on the blog - but the current version up there does not have the latest working OTA. I'm in Spain right now doing a little contract work but I'm back 12 days and I plan to update the BitBucket. So yes.

    1. Looking at the schematics it uses a 25Q80BV which is 1MB Flash. This is big enough for OTA I'm currently emulating on a 4MB ESP-12E while waiting for my ordered sonoffs to arrive.

  7. Hello, it seems the led on the sonoff board is red/green. You can control the green led by setting gpio 13 low. This can come in handy for some kind of visual indicator that the unit is doing something.

    Have a nice day!

  8. I've searched and asked and haven't found any answers to this:
    What kind of security do these provide?

    SSL? Authentication?

    Or is it all unencrypted, unauthenticated HTTP requests?

    1. Ah. So that's probably why I just got a refund, I have to admit I'd not been keeping up with the campaign.
      You think there'd be more info though not just a refund.
      Oh well just have to make our own I suppose.

  9. Hi Pete,
    I've reprogrammed my Sonoff such that it will blink the LED and trigger the relay but it won't connect to my wifi. Would you mind posting your code so I can compare what you've done to get it running ? Many thanks

  10. Theo: Well done - glad it works - I have 3 on the way any time soon - great that GPIO13 acts as an indicator because that just happens to be the pin I already use for status information such as login etc... so that's really great.

    Looking forward to getting back to the UK to test these out.

  11. Unfortunately, they never got much beyond 24% of their target, which is a shame. We all got our refunds, which is okay, but I'd rather have had the Sonoffs instead.

    You seem to have an open channel to them, Pete. Can you ask them if they're going to run off a few smaller batches to fund a larger run? They must have some stock (you generally can't buy injection molded cases by the onesey-twoseys) and they already know that they have a market for several hundred of them ...just not the two thousand or so that they were aiming for.

    It would also be quite interesting to know what the breakdown of orders were between Sonoff and Slampher units. 🙂

    1. I'm confused!

      I ordered 3 pc's Sonoff on THE Itead website, and they were delivered within 2 weeks.

      Version I received is without THE 433Mhz receiver. Possibly Indiegogo was for The version with 433Mhz.

      1. Gerardwr,

        Yes, the Indiegogo campaign was for the latest version with the remote control. The one they're currently selling doesn't have the remote, doesn't have the colourful end covers and is a little cheaper.

        1. OK, that's clear for me now. Bundled with my Sonoff order was a flyer for the Indiegogo campaign, promoting a Sonoff + 433Mhz remote for $5.

          On the Itead website the Sonoff + 433Mhz is now advertised for $7.20.

          So they seem to go ahead despite the cancelled campaign.

      1. Thanks Pete. We can all forget about ordering anything from the Middle Kingdom for the next month or so, then (the post holiday catch-up always bogs things down for another couple of weeks, too). 🙁

  12. Love your site!
    How are you getting to connect MQTT to the sonoff modules?
    I have hooked up 4 of them and using the APP and looks like a great device.

    Thanks!

  13. Remove diode, on place of green add pull-up resistor 1.5k to +3.3v side, and add push button to 0, ready for switch/relay for wall mount console 🙂

  14. This was part of a reply on the Itead forum: '...yes, we are still developing more Sonoff versions, like low voltage version, version with temperature sensor.'

    Looks quite interesting if they continue to develop these low cost modules.

  15. Small correction of the pin description. Actually, the square pin is 3V3, not Ground. The connection picture is correct.

  16. After reading your nice article i order some of these nice devices.

    I tried to reprogram them with the Arduino IDE. I do get serial prints but no wifi connection. Also the delays are shorter than they should be.
    Can you tell me which IDE you used and which crystal settings you used?

    1. I used the standard windows "unofficial" development environment and there are no crystal settings to choose from (apart from the ability to double the frequency which I never use). I do not have enough experience of the Arduino environment to comment much - but I don't remember setting a crystal frequency when I used that.

  17. Thanks for you feedback.

    It is very strange. One time a got a short connection to my network. After that one time no success anymore. Tried it also at two of my devices.

    Flashed the same firmware on my nodemcu and it is working fine.

    1. I've also tried to reprogram it with the Arduino IDE and ESP8266 framework 2.0. I get full control of green LED, Relay and serial port but no WiFi.

      Just trying the basic WiFi.begin(WLAN_SSID, WLAN_PASS) but it's stuck at WiFi.status() which usually works like a charme on every ESP-xx I've tried with the Arduino IDE.

      The Sonoff worked with its standard firmware so I can't think of any hardware issue. I was also thinking at crystal but I see from the schematic that it's a usual 26MHz.

      I will try Jiri's firmware to see if it works. Any other ideas, please share. Thanks

      1. Obviously I can't get into supporting other people's software.. but all I can say is make sure you're using something that YOU know works just fine on a normal ESP-12... I had no problem at all - worked just fine.... so I'm not the best one for offering debug advice 🙂 I have some more coming very soon - I'll update the write up - I do know that my board was not the latest version.. I don't think the green light was hooked up to the ESP... the ones I have coming will be the latest.

        1. [SOLVED]
          The problem was an incorrect setup of the Arduino IDE.
          The Sonoff has a 512Kb Flash connected to the ESP and WiFi will not work if the IDE is not configured with the correct "Flash Size" in the Tools menu.

          I normally use ESP modules with 4M Flash. But if you have Flash Size = 4M the WiFi of the Sonoff will not work.

          1. You're right, the flash chip is a Winbond 25Q80 1Mbit.
            However for some reasons I have to investigate, the only settings that make WiFi work with the Arduino IDE are with "Flash Size = 512K"

  18. I purchased some Sonoff's too with the intention to replace the firmware. Valuable information for that here, thanks for sharing. Kudos for Peter.

    The original firmware and the App work fine, but after a while (sometimes 5 minutes, sometimes 1 hour) the Sonoff looses connection and the green Led that used to be ON starts flashing (2blinks then pause) as if it is seeking connection. Sometimes, after a while the connection is automagically established again, the green Led comes ON again, and the App can switch the Sonoff.

    I am not sure if this could be a problem in my Wlan, or a problem with the Sonoff cloud server.

    I raised a problem at the Stead site, but no real response from them yet. Chinese New Year, maybe?

    Anyone recognize this issue?

    1. Hi

      Right - a couple of things - firstly - yes they just started Chinese holidays.
      Secondly - I've no experience of using their cloud - that is their thing and what they want to do but from day one I never had any intention of having my house control at the mercy of someone elses cloud - hence I use a local Mosquitto installation on a Raspberry Pi and my own software to talk to it - in the ESP-Arduino environment there is an example of a basic MQTT setup as there is with the C PC environment elsewhere - it's basically a case of taking that and using it as a base to turn the Sonoff on and off.

      1. Hello Peter,

        I fully agree, don't want to use their cloud solution either!

        Tried to sniff the Sonoff network communication for TCP or UDP packages, but considering the Sonoff uses 802.11G only (and my Mac is 802.11G right now) did not succeed yet.

        But before reflashing the original firmware I was curious on the quality of this firmware and the App. App works fine, and apart from the lost-connection-problem the firmware responds nicely and quickly to the App.

        It's a neat little device as an ESP development platform. The quality of the hardware looks great, and the price is low. I had expected the device to be more popular in the ESP community, but of course it's quite new.

        I'm going to try to backup the original firmware (you'll never know) and then reflash it with a standard Arduino-ESP sketch. See if that solves the lost-connection problem.

        Cheers!

  19. Has anyone tried flashing the Slampher light bulb device?

    Despite holding down the button while powering on, i cant' seem to get the thing in flash mode?

    1. Hi canta,
      thanks a lot for catching this!
      The issue with the Arduino IDE and Flash size was definitely due to having the Flash chip not completely clean. I think this prevented the WiFi parameters from being stored properly in Flash, unless trimming the settings down to 512K, but wasting the other 512K.

      Now I can use the full 1M Flash with WiFi working fine.

      Thanks again!

      1. this is the same situation when you try to glash "unvirgin" with lua or micropython or arduino or other.
        you need to clear the whole flash first

        if you buy from cheap esp8266 modules on the net, they do not flash any firmware, the flash is empty
        this is the reason, you can use the module right away:D

        gladly, seeing your issue and can share a bit knowldege

        1. I'm not sure I understand this... I know the principle of flash having to be cleared and set to FF as you can only actually write a zero - but I reflash my boards all the time with new software and never empty them out first - or at least not deliberately... so every time I'm programming them - I'm programming them with something in them - why would it matter if it was a completely different program - in fact thinking about it I try different programs in the same chip time and time again. Not following this one...

    2. I was able to flash the Slampher. You need to do a bit of soldering work. According to the schematics shown in http://wiki.iteadstudio.com/images/e/e1/IM151116005-Slampher-View.pdf, there is R20 that connects the GPIO0 to GND through switch S1 (See section A8 of the schematics), but R20 is missing in the board. That is way, we can not boot the ESP8266 into programming mode. I assume R20 is a 0 ohms resistor (0R|J|0603), so I just soldered a small cable on the terminals where R20 is supposed to go, and that is it. Now you can flash the Slampher the same way as the Sonoff.

      1. Thank you Alberto! I could not figure out how to put the Slampher into flash mode and thanks to your post it is finally working. Thanks again for taking the time and posting it.

  20. I have just installed a water meter (1 pulse per 1 Litre) and I am thinking of using one of these to read the pulses and send via mqtt to nodered and then to emoncms and other HA apps.

    The idea is to remove the relay and associated components, isolate all the mains routing and flash new software which will turn the relay output into an input.

    That way I have a cheap mains powered self contained ESP!

    1. this is easy to manage your own software/build :).

      learn a bit, and pick opensource library, use the library or make custimization, and make it work as a device/system.

      one more consideration, if your meter is outside or not covered area, low voltage power input is recommended..

        1. I always believe everyone has his/her project prior esp8266.
          I learnt microcontroller 8051:D at school back then as a hobby.

          if you have already mqtt infrstructure running, yeah sending/countung pulse is easy with just one topic or lett a bit processing on esp8266.
          coding is minimal...

          I uses mqtt, and working with 6 esp8266 and arduinos(my rack server controller). those arduinos migrated to use mqtt last year. and esp8266 is on going progress (slow due on daily works and taking care my toddlers).
          teared down un-needed arduino devices last year since pain in the b*tt to add more devices and maintain the mesh system. the goal is replace by esp8266 with mqtt.
          I repurprose all sensor and I/O devices to use on esp8266.
          mqtt is a life saver for me

          ota on esp8266 is hit and miss, better than first release. I do using wifi to update sketches since devices are everywhere and hide somewhere. I would say 70% works and 30% fails. this is better than nothing.
          since sonoff is plugged to 120V, I can not complaint on 30% fail.

          arduino is very stable running and controlling server rack cooling. I am impressed with it.
          I am torturing esp8266 to send mqtt topic/msg automatically and response to mqtt/topics from my command node(agent). 2 months already passes, my goal to see esp8266 is robust or kind of robust compared with arduino.

          good luck on your project!!!

          btw: any suggestion on opensource AI/fuzzy logic core?
          I need to build "a brain" from ground to up. let the system learns and thinks to decide what to do via mqtt:D *evil laugh*.

  21. Something has changed... they've sent me the new "RF" Sonoff - which is like the one I had before - but says RF... meaning it has RF and WIFI...

    BUT whereas before, GPIO0 went to that nice, handy big button - it now disappears somewhere into the radio chip - and unless I'm mistaken that now makes it a pain in the bum to hold to ground while reprogramming the boards. Did I miss something?

    1. Can you post external/internal pictures of your new sonoff delivery?

      I just order 9 sonoff (non RF) since they have Chine new year 10% off, the price is lower than banggood. US $5.80 each; inculding shipping fee.

      I make "roughly" assumption that those sonoff are identical with the one from banggood.
      Bought 4 from banggood (US $6.10 each with free shipping and discount), and working on those.

      based on your post, I should be ready to do a little surgery on sonoff that came from itead directly..

  22. I am a little annoyed, in that i ordered my Sonoff RF's from ITEAD after the crowdfunding thing fell through, and I fully expected to get the little rf controllers with them as shown in the photos which differentiate them from the standard Sonoffs. However they did not come in the package I received today.

    Checking back at the product description I see there is now a one liner down in the description saying that they are not included, but i am pretty sure that it as not not there when i ordered

    kevin

    1. the pics form itead website is missleading 🙁

      I guess, they do not know on how to write "correct" description.
      reading the description is make me to learn hard to understand

      I would love when they:
      1) leave descprotion in their native language(mandarin)
      2) add extra descroption in english (broker or not should not matter).

  23. Perhaps I am being stupid but one of the 2 schematics shown at the top seems to be reversed. The script says that the lower square pin is GND and is closest to push button in top diagram. In second schematic VCC is shown as being closest to push button. Anyway I think I have fried my first Sonoff board.

  24. I nearly made a mistake there and fixed a wiring diagram that was already ok - the actual wiring diagram is correct and I've now clarified that the square hole is in fact 3v3.

  25. one of my first four order on sonoff from banggood is defective.
    just friendly reminder, try your sonoff first with their app and let test for a day or two to make sure not defective one.

    the bad one has issue on disconnecting wifi randomly ~ 10m to 30 mins..
    the simple way is pinging sonoff and do turn off/on or make a schedule ( turn on/off ~ 5 mins to 10mins period ) via theri app.
    I try to turn on by connecting to AC input today again, yeah.. no light on led. something on PSU circuit could wrong.

    working on banggod to resolve this issue. let see if I can get replacement or eat the cost without replacement...

    I think, Itead should do better QA 🙂 since sonoff is getting popular for alternate reasonable price of wifi(mqtt/web/my cloud))-swich solution.

    I received V 1.0 sonoff from banggood,

    cya

    1. Hi,

      Have the random disconnecting from wifi problem too with my Sonoff unit.

      Raised a ticket @iTead claiming a "defect", and got this response today:
      "The problem is not about the Sonoff itself but about firmware,please be patient and the new firmware is coming soon
      After upgrade the firmware, it won't be offline
      So, my suggestion is there is no need to replace"

      May be a good idea to await this new firmware, as it may come with good instructions on how to flash it 🙂

      1. I have one sonoff in operation - I never bothered with their software - it's just an ESP12 unless you really need the RF stuff.. I put my own software in and it is operating flawlessly. You could take the ESP/Arduino MQTT software and use that as a base - that as far as I know is reliable. In the unofficial development environment - TUANPMs MQTT example is a great base - all you have to do is grab the device ID and subscribe to that plus a keyword of your choice - and you can then add simple code to turn the port bit on and off.

        1. That came out - I have TWO programmed up - but only one actually sitting controlling something full time right now - busy office building so no time to package stuff up etc and do the actual home automation - that will come and Sonoff is likely to play a big part.

          1. Like the Sonoff a lot too! It contains a nice power supply, it's not expensive, and the housing has some space left for additional electronics.

            Good luck with your building adventure 🙂

        2. I'm currently developing with the Arduino IDE for a Wemos D1 board so I don't have to bother with FTDI's and toggling GPIO's high and low.

          When finished I intend to flash my software to a Sonoff. Until that time i'm testing my 3 Sonoff's with the delivered firmware.

          Thanks for the MQTT suggestion, but it is not for me, ATM.

          Currently I'm using the standard IOS LightwaveRF App to control the ESP8266 using the LightwaveRF API. The App controls switches/dimmers, and supports Timers and Sequences. My ESP sketch (development ongoing) simulates the LighwaveRF-WifiLink gateway.

          1. mqtt is easy for many to many communication.

            only a down side, you have local mqtt running or ge free clould mqtt on the net.

            Done building sensor and the code for now
            and focusing with my spare time on sonoff with my code

            all communucation is via mqtt :).

            you will not regret to jump on M2M protocol since easy to manages nodes/devices.

            next target is diving to AI/Fuzzy logic to control all devices.

      2. mine is Dead with no led activity:D
        banggood send me a replacement for that 😀

        I am pretty sure something wrong wth hardware,
        I will dissect when time is available..

        let me know if you are done with firmware update.

        btw, you save a whole flash memory using esptool :).

          1. well. you need to know memory address to start
            or just blindly to dump whe whole from 0x00 to memory size....

            this is a starting point -> http://www.esp8266.com/viewtopic.php?f=6&t=524&start=8

            yeah, I am running ubuntu on my laptop :).

            ex: esptool --port /dev/ttyUSB0 --baud 115200 read_flash 0x00000 flash_backup.bin

            the problem is, once you read the flash, you have to set gpio0 dancing to set serial mode loader.

            have fun!!!

          2. oops forgot. 0xfc000 (esp data) is where esp save wifi ssid and password :D. as I remember. need to check on forum

  26. I don't remember seeing so many responses to one item! THEO - I fancy giving your software a go... 2 QUICK questions for you... you have 2 BIN files up there.. where do they go - is it 0 and 40000 or 0 and 80000 ??? And to save my much heartache - your makefile - is that set up for Linux or Windows???

    Pete.

  27. Pete, glad you want to give it a try! The bin files are actually the two OTA files to be provided by a webserver. If you manage to compile the initial flash file you can compile these OTA files too. The README.MD files tries to explain the process. The make file is setup for Linux using the esp8266-dev environment which in turn relies on esp-open-sdk.
    The initial sonoff esptools command line looks like:
    esptool.py --port /dev/ttyUSB0 write_flash -fs 8m 0x00000 sdk/bin/ boot_v1.4(b1).bin 0x01000 .firmwares/user1.bin 0xFC000 sdk/bin/esp_init_data_default.bin 0xFE000 sdk/bin/blank.bin

    1. Sadly amending MAKe files to make them run under Windows is one of my WORST skills - ask Richard of RBOOT fame. I wonder - has anyone in here already translated this one to run with Eclipse in the unofficial dev environment for Windows. It would be good to run it and compare to our own offering - Ilike your multi-use of GPIO0 - and of course we're currently struggling with the external access bit - the dns lookup works - but for reasons currently evading us - external IP just does not work.

    1. Oh good - just to save screwups - so this bin fine is run at 00000 - and where is that - did you overwrite the first of the two bins I spotted or did you put it somewhere else?

      I'm quite excited now - something to play with.

      Pete.

      1. No. This user1.bin file runs at 0x01000 together with three files from the sdk: a boot.bin file at 0x00000, the esp_init_data_default.bin file at 0xFC000 and the blank.bin at 0xFE000

        1. Theo,

          I'm new to this and I'm having a hard time following this. Is there a start to finish step-by-step guide to getting these Sonoffs setup to run MQTT? If not, is there a guide for just programming 8266s like you suggest in general?

          1. want an easy one? try esp8266 arduino...
            you can write code with mix esp8266 style with arduino style (setup and loop).

            follow the instruction on esp8266 arduino, works fine with knolly or lmory github pubsub/mqtt .

          2. Peter great blog site!
            I am getting a few Sonoff and will give it a try with MQTT as I want to use them in a larger home automation project...

            Theo it seems you have done quite a piece of work with OTA and the Sonoff app!
            It would be great if you were able to post a "start-to-finish" guide.
            I've installed the esp-open-sdk but i am stuck with the OTA. How can I set up a local OTA server ("Install a local web server for OTA and copy directory api in webroot... etc)?

          3. Mauri, what my sonoff OTA needs is a webserver that will provide the user1.bin and user2.bin to sonoff just as normal webpages. I use Debian Linux (both virtual on windows and native on my NAS) and installed apache as the webserver. The default apache installation will provide a webpage stating that the apache install is succeeded. Google for apache installation info.
            Depending of the version of apache you may find the apache webroot as directory /var/www. Copy my api directory into it and change access rights to it with chmod 777 /var/www/api -r.
            In addition you'll need PHP installed on Debian as I use it to copy the compiled firmware from esp8266-dev to apache during the make register phase.
            I hope that makes sense...

      2. Pete, just released a version with serial MMI support allowing to use the provided firmware and make changes to SSId, password and MQTT host easily. See README.md for available commands.

          1. Thanks Peter and Theo!
            To the OTA server, yes Theo it all makes sense. My esp8266 dev environment is Raspery Pi (the 3.3V and the UART pins of the GPIO come handy on my desk) plus Node.js. I don't use the apache server, i use instead a simple Node server implementation for the HTTP post. I don't have PHP installed either so I will replace the PHP script back to the fota-client.js. I understand you just copy user1.bin and user2.bin over to the web (OTA) server.
            Will experiment more when I've got my Sonoffs (soon hopefully), and let you know how far I've got.

  28. I found this post very usefull, and managed to reflash my sonoff to make use of mqtt. I didn't have any luck with the slampher however (lightbulb adapter) the pinout for the serial connection seems to be identical as for the sonoff but serial connection fails... Has anyone had some luck?

    Alex

  29. It would be great if they could breakout the unused GPIO's 🙂
    I modified a board (non RF one) using the GPIO5 with a temperature/moisture sensor using Blynk to see and control (fan). Worked really great .. hadn't secured the little wire on the unused pin enough though :-/ broke off. Used the GND and 3.3v from the 433 radio pins.

  30. Hi Peter! I've got my Sonoff, struggling with getting into flashing mode. Can you confirm that led stays off in flashing mode and serial interface is set to 115200 N81?
    Thanks!

      1. Hi, Yes, I meant when you flash you own software - "Use FTDI at 3v3 setting – in the original boards, press the large button –THEN power up FTDI." The "large button" is the GPIO0 button on the Sonoff, The led on the Sonoff is off and serial is set to 115200 N81, right?

        1. Hi Mauri,

          I just flashed my Sonoff and the green Led is OFF during flashing (it is attached to GPIO13).
          I use platformio/atom/Win for my MQTT-ESP programming and I don't have to bother with setting com-port or speed (it does that automatic), even OTA is a breeze sinve you only have to provide the ESP's IP-adress in the platformio.ini and it does everything for you automagically.

          Have Fun

          1. Hi. thanks. I managed to flash the sonoff with esptool.py and connect to node-red/MQTT with Theo's firmware... indeed you don't need to care about speed, etc. (it is just me being new to the esp programming :). Setting up the OTA next and a real deployement with a few sonoffs.. it will be some fun!

  31. Hi guys,
    could someone help me to configure the switches sonoof with tasker applications for Android?
    it would be nice to be able to command our switches via pre-set tasker events, such as:
    voice commands to turn on a light,
    Through the phone GPS to turn on or off certain lights when they are close to home,
    etc ...
    I thought to proceed by studying the manifest of ewelink application and configure actions inited on tasker app, but I can't figure out what actions are useful for my purpose in the Manifest file you have any good advice?
    Thank you

  32. Hi,

    So, if it's a non-RF Sonoff, this is still working ?
    I have open mine, connect the FTDI. I check twice but it's as described here and an instructable howto I find (but in spanish, so look at pictures only)
    When press the switch button and connect then the FTDI to USB, yes can see the Sonoff is "reacting" as the LED is not blinking at all (normal boot, blinking, I think look for wifi)
    But once in Arduino IDE (1.6.7 with ESP 2.1 boards addon) I can compil a sketch for it but I get :
    warning: espcomm_sync failed
    error: espcomm_open failed
    error: espcomm_upload_mem failed

    This after the FDTI has briefly blink. What I understand is that by some way the FTDI start to communicate but no answer on Sonoff so hangup.
    I'm scared these versions are not working and must do some soldering or anything like the RF (but I'm having the non RF, with a switch button and picture look like this article, not the 2 others articles of your blog)

    1. you need to press the button first and power-on your sonoff to go to serial flash loading...

      1. Yes, have done that. The Sonoff is reacting right (no LED on, without pressing the button the LED is flashing)
        But the uploading is going wrong, don't understand why

        1. you need to erase the whole flash memory first, I posted before.

          if you have newer sonoff module, yeah the button is NOT D0

          the clear difference on those is, the switch button that connect to D0 has no hole for LED on plastic cover.

          the other module that switch button not connected to DO has hole for LED on plasti cover.

          if you get newer model, you need to mod a bit. search ot Scargill newer post.

          BTW, I received 2 days ago, a replacment that switch button does not connect to D0.
          yes, receive newer model wifi only .

          1. Thanks for the tip how to see if it's the old or new.
            Sor for mines, I have not a full hole for the LED. I mean from the inside can see there is some "digging" the not going through. So from outside the box, the plastic is full no hole. This must mean it's the old version so ...

            So I go again with your command to erase the memory, but esptool is complaining it cannot connect to the ESP. The LED for transmission on the FTDI is blinking some time and stop. Like when flashing the firmware.

            I try 2 different ones in case one was break, but the 2 sonoff have the same reaction.

            So is the hole "complete" on the new version or like what I have just some digging, meaning I have to go with the new model (but when pressing power button and power on, I can see that the Sonoff is clearly not starting like normal, no LED blinking)

  33. I have what I think are early Wifi only Sonoffs (button and LED holes in case). I have successfully loaded a test OTA program after erasing the flash using esptool.py. I was able to reprogram the device using OTA a couple times. Then I tried to load a larger program and it failed to upload. Since then I have been unable to upload any program to my test Sonoff. I am able to connect with esptools.py but the upload from the Arduino IDE always fails. Judging by the number of periods printed before the "read 0" message below it does not fail at the same point. Sometimes there are no periods and other times 50+ but usually <~10. I have tried another Win 7 PC and another Sonoff with the same results. I have tried several power supplies up to 3A capacity. I am able to upload the same program to ESP-12 modules without difficulty.

    Any suggestions why it works one day and not the next?

    writing flash
    ...... read 0, requested 1
    warning: espcomm_send_command: didn't receive command response

  34. Hi John,

    I have a few SonOff's where I had more or les the same problem.. I think it was a power-supply-problem.
    I solved it by uploading a small BasicOTA-program by FTDI onto the SonOff and the connect it to mains (DISCONNECT the FTDI!!) and flash "the big"-firmware over-the-air onto it.
    Probably my FTDI could not supply enough current for the Sonoff to program. Normally you just have to supply the ESP8266 but in this design there is a whole lot of passive components also on the board that might produce a load the FTDI cannot support.
    I am just looking for the IP-adres the BasicOTA produces, put it into PlatformIO and upload my new firmware.. Done!

    Hope this helps.

    1. Oh hell yes - in my experience the FTDIs at 5v can supply lots of current but by the time they go through their internal regulators to provide 3v3 - there is JUST enough power to program Sonoffs and other devices with very little spare.. A separate supply (don't feed power from FTDI - just ground and the two serial lines) is a better idea though I seem to get away with it with mine.

  35. In my case I don't think it is a power supply problem. I made a strip board circuit with a LD1117 3.3V regulator using the USB nominal 5V. FTDI connects on one end and the Sonoff on the other. I also tried my bench supply capable of 3A. My troubles have been with my two Win 7 desktop PCs with Arduino IDE 1.6.8 and esp8266 board manager V2.1. As a last result I figured out how to get python, etc. installed on my Win 10 laptop. Using Arduino 1.6.7 and esp boards V2.0 I can load programs to my Sonoffs first time and everytime (so far). With the Sonoff connected to the laptop I can load OTA from my Win 7 desktop while still observing the results on the laptop serial connection. When I get the chance I'll try 1.6.7 and V2.0 on Win 7 and see if it solves the problem.

    Now if I can just get the Sonoff to connect to mosquitto. Solid Wifi connection but so far I haven't been able to get a MQTT connection. I have several wired Ethernet and ESP-12 mosquitto connections that continue to work fine.

    1. Still sounds like your desktop cannot provide the current and your Laptop can...
      Feeding a LD1117 from the USB still makes it work through the current-limmitations of USB (maybe you Laptop has a "power-USB"-output (my Asus laptop has something like that but you have to enable it).

      My SonOffs work fine connected to Mosquitto (internally aa well as on their public server on the internet).
      I did have several problems using HiveMQ but these were mainly because of the stability of their public MQTT-server.
      Next step for me will be involving Node-Red into the equation.

    2. check mosquitto logs, and will tell you the error...

      I already 4 sonoff connecting to local mosquitto . solid for 2 months with connect and reconnection..

  36. MQTT problem was a cockpit error. I still don't understand my problem loading programs through COM ports but I do have a work around. Using a USB port on hub seems to work reliably. Everybody seems to point to power as a likely problem and a powered hub seems like it fits that pattern. However, I was watching the power consumed by the Sonoff while loading a program. Using one of those USB pass thru power monitors I checked the current consumed and any apparent sag in USB voltage. My LD1117 regulator board consumes ~11mA with no Sonoff connected. While loading a program it is only ~47-50mA. After the load is complete and the program starts it draws ~85-90mA with the relay off and ~112-115mA with the relay on. None of these power levels "should" present any issue for a USB port. The regulator board has a 10uf tantalum capacitor on the 3V3 side which should help with any peaks.

    It is still a mystery but at least I can now reliably program the Sonoffs. The Sonoff program and associated Node-red flows are still a work in progress. Its all working but there is much room for improvements. I never would have known where to begin without the help I found here.

    Thanks to all...

  37. Dear Peter,

    Love your Site! Lot of good and interesting info! Thanks for sharing!

    Ive succesfully uploaded the MQTT OTA firmware to my sonoff.

    I have an arduino board with ethernet shield which is supposed to send de MQTT commands to control the sonoff but I cant make it work. Does anybody knows which library or code is the best in this case?

    Thanks!

    Matias.

    1. Thanks for that Adri

      Well, some comments about this one - I've not seen this item before - and it has two things that I can comment on - firstly - the relays are more like the 10 amp relays I'm used to.. secondly it also seems to have isolation slots. I can't comment on the power supply as I've not seen this particular model - I wonder why they didn't make it part of the board.. I DO note they've made space for a DHT22 - which is GOOD - but I don't see the point as that power supply SURELY has to have heat output which would corrupt any DHT22 reading - on the other hand I see a decent connector there - something missing on the SONOFF units. The price is good - but for the post - which is nearly as much as the unit itself. However I've sent for samples and we'll do a review!!!

      1. The DHT22-sensor is surely not for ambient-temperature, it would measure the inside of the enclosure. That task could be done with a much cheaper sensor. I Think they knew so they made it optional (otherwise the DHT would make 20% of the total costprice).

        They probably used the standard power-supply to reduce cost (these things are dirt-cheap).

        I would put an MQTT-client on it and use it for my Domotica (it is not often that you need 2 switchingcapabilities at one location but at this price it is nice to have)

        1. Assuming they send me samples - putting MQTT on is exactly what I will do... and for switching 2 items in one place.... if you're doctoring existing house wiring there are often 2 switches together....

  38. Anyone worked out the pin-out for the 5-pin version as opposed to the 4 pin that Pete mentions here? I want to know what to plug my FTDI into without frying anything. I've just received 10 5-pin versions through the post and would like to reprogram for MQTT.

    Sorry if I missed it in the many posts above!

      1. Hi Robert,

        Thats not the version John was looking for... looking at the layout that is the version without the power supply the "industrial version".

        As far as I can see there are 3 versions:
        the first consumer-version with 4 holes to attach the "FTDI" (in a nice housing with open holes for LED and Switch -which is connected to GPIO0)
        the second consumer-version with 5 holes for the "FTDI" (in the same housing but the LED-hole is not completely through and the Switch is not connected to GPIO0)
        the third "industrial-version without a housing and without a power supply

        GRTZ

        1. Hmmm, interesting. I actually bought 3 Sonoff with housing (this product: https://www.itead.cc/sonoff-wifi-wireless-switch.html), and I on the inside they all had this board — it even says Sonoff TH on the PCB.

          I think the switch was connected to GPIO0, since I was able to upload a custom program by turning it on while pressing the switch. And the 5 pins were the same as listed in that diagram: VCC, RX, TX, GND and GPIO2.

  39. I just received a batch of Sonoff TH and Sonoff SV. The TH model has 5 holes. The 4 holes closest to the transformer are the same as the 4 hole versions I received earlier. The fifth hole is GPIO14. I have been able to program them using the same methods as the earlier 4 pin version. These came in the same case as the original 4 pin version. The Sonoff SV is a different animal altogether. It has a 4 pin header on the far right edge for programming. In the middle it has a 3x3 header with 3x Vcc, 3x GND, GPIO4,5 & 14. It is powered by 5-24 VDC. It is designed to switch this DC voltage via the relay. By cutting some traces you can power the device with 5-24VDC but switch another source. I have not tried this yet. I have tried a couple I2C devices connected to GPIO4 & 5. They worked great. The Sonoff SV comes without any case. All of the models I have received have the button connected to GPIO 0. I use Arduino 1.6.8 to program these devices initially through FTDI but then by OTA.

    1. I concur with Robert and John B - I received a batch of standard Sonoffs and Sonoff SVs. The "standard" Sonoffs when I break them down are the 5-pin Sonoff TH board, but come in enclosures like the "standard" Sonoff.

      Using the link that Robert posted I've worked out what the pins are, soldered a header to one of them and have attempted to upload Theo Arend's firmware to them. The upload happens with just a few retries and baud tweaks, but I cannot for the life of me get the device to boot up. I then tried a "hello world" type of program (toggle led state on button press) and that doesn't work either.

      Next weekend's mission will be to do the same again with another of the Sonoffs to see if I have got a duff one.

      1. Received same with 5pin Sonoff TH board. Firmware successfully re-flashed with cp2102 adapter.
        As I see on schemas - 5-th pin is MTMS or GPIO14, I soldered a led between it and GND and it works great 🙂 Will try to wire PIR motion sensor to this pin.

        1. Hi. I have the Sonoff TH also. Is there any way to get 5v safely off the board to power a Nextion touch screen? I see from the schematics there is a 5v bar, but whether it's accessible or not is my question. Thanks, Andy.

  40. Ah. That's disappointing as it would make a good WiFi Thermostat. With the addition of the Nextion to set and view the current temperature and set-point. Back to the drawing board! I have been reading your blog with great interest and appreciate all your hard work. Thanks!

    1. Well I use our own board made with the Nextion in mind (see that project in this blog) - just messing around with 3d printing right now to make a thermostat case...

  41. Am I right in assuming that the Slampher wireless light holder requires the original wall switch to be in the On position to operate (so as to have Live and Neutral available)?

    If so, that's a real downer as I want to be able to walk into a room (or leave it) and hit a switch on the wall, not 'pre-plan' and dig out my phone or a keyfob (you can't do that with arms full of junk, but you can hit a switch with your elbow.

    The wall boxes for switches where I am are only two-wire (Fixed Live and Switched Return - or it may be Fixed Neutral and Switched return, it's rural Spain and wiring standards are a joke) and there are no Earths, so there's no chance of powering anything 'within the box'.

        1. The jigsaw pattern is, from what I could work out from the Chinglish, replaceable with artwork of your choice...

  42. The last batch of Sonoffs I received were the TH model board inside the original white case. I tossed the case and fitted one to a single gang (US) blank cover plate. The tiny button and LED poke through holes in the plate and the top of the relay is glued to the back of the plate. It works great as a remote switch inside a plastic single gang box. I added a DS18B20 in the cover plate as well connected to GPIO14. However, the temperature reading is almost useless as the enclosed Sonoff heats the cover plate a few degrees F. If you want an accurate temperature reading plan on separating the sensor from the Sonoff.

    I'm using Imperihome, MQTT and NodeRed to control 8 Sonoffs so far. I never would have made it this far without all the help found here.

    1. Glad to be of service, as Robin Williams once said - yes, temperature sensors anywhere near a mains control board not a good idea. I usually mount them externally underneath a unit in the hope that self-generated heat goes UP 🙂

  43. I'm interested in these to control heating etc in my local church.

    Being a public building i have to be mindful of compliance issues.

    I was encouraged by the comments on mains isolation etc, but wonder if anybody has seen or heard of one with approvals?

    Also wondering about rating - the banggood ad that brought me here said 250v, 7a. Im assuming thats 250v as in uk mains being 230v, but 7a is a bit vague. Our heating systems have pumps etc so though continuous load is quite small initial start might have a fair inductive component in it...

    Any advice (even go and read their website!) gratefully received....

  44. US heat pumps have 24VAC controls. MUCH better to control the HVAC equipment via this control voltage rather than attempt to switch the mains power. Not only is it much safer for you but also for the heat pump. Many have additional safeguards such as a 5 minute delay before restarting the compressor, defrost cycles, etc. By directly switching the mains power you may bypass these safeguards potentially shortening the life of your heat pump. Essentially replacing or augmenting the thermostat with your controls keeps the manufacturer's safeguards in place. For US heat pumps you would likely want 2 to 4 relays per heat pump depending on how much control you need. This can be accomplished with some models of Sonoff but not "out of the box". Google Arduino thermostat or ESP8266 thermostat and you'll find more than you can read in a day!

    1. I would much rather control 24v than 230v - but in the UK, the latter is pretty much the standard. Oil or gas heating systems would normally have their own delays - in my software I never switch heating systems on or off more frequently than one minute absolute minimum.

  45. Thanks very much for the replies. Very much appreciated. Perhaps I should have expanded my original question a bit. Our heating system controls are very simple - two thirty plus year old boilers, firing two independent heating systems, each controlled at the moment by immersion heater timers. I imagine these have relays rated at 15A resistive. Anyway they have no issues. The 240v output from each of these is connected to the relevant pump and the gas valve/blower on our simple boilers. No smart stuff sadly. I'm familiar with other systems and if there were 24v (or the other common in the uk, at any rate, 0-10v dc) control options I'd take them, and just use a compliant mains adaptor, simple.

    I very much doubt that the gas controls draw more than 0.5A on either boiler. The pumps are probably low powered too, less than a couple of amps running. So in all liklihood is a 7A relay would be probably be fine, even if I down rated it by 2/3rds for inductive startup load. Just wondered if anybody might have more information. I will check the pumps rating plates when I can get into the boiler room. The switching frequency is very low, they are off, powered for the whole of the heating period, off again. They're used as availability timers/controls, not thermostats. All I'm looking to do at the moment is replace the existing switches with something that can be controlled from outside the room.

    The big issue is compliance - if the units are marked to show they are ce compliant or not. If they're not, then basically I can't fit them unless I have conclusive proof that they meet the relevant standards, which practically speaking I won't have. Our insurance company would have a fit....

  46. I have an alarm system (old fashion GSM alarm with pir sensors and siren) do you think i could connect the siren wires to the sonoff switch and have it somehow tweaked to send an email to me when the alarm is triggered?could you give me a basic way to start?

    1. Simply Google ESP8266 email - you'll find out soon enough if this can be done. Personally I use the ESPs as end of chain controllers - with Node-Red on a Pi doing the controlling - email from there is trivial as there is a node for it.

  47. Can I update firmware of the "Sonoff - WiFi Wireless Smart Switch For MQTT COAP Smart Home" OTA or do I need to solder some headers onto the board (I'm pretty reluctant soldering on mains devices - which I used to do 100 yrs ago (or at least 20)). I couldn't find any information about this, but to me it looks as if there are no headers on the board itself...

    Any hint appreciated

  48. Has anyone used the Sonoff's with Home Assistant? I can't seem to find anything documented successes; though its just getting a MQTT device to work with it, so it *should* be pretty trivial.

    1. Yes and quite successfully. I decided to write my own code for the Sonos. I found the code mentioned above overly complex. All I want a Sonoff switch to do is turn on or off and remain in the same topic because all mine are permanently installed and won't change. The switches are "dumb" anyway as all automation happens in Home Assistamt. Anyway it's so easy to take them apart that OTA updates just aren't necessary for me. Anyway I have a few that are working with Home Assistant and they're great.

  49. Hi, I'm happily running a Sonoff TH with arendst/Sonoff-MQTT-OTA-Arduino software. But would like to add a DHT22 Temp sensor to it. From what i see arendst's Software does not support the DHT22. And how to get Peters software onto the Sonoff so it works is a bit unclear to me. Is there an easy alternative?

  50. I'm currently tearing apart the mobile application of sonoff and slampher. I made some good progress about it. Turns out mobile application is based on their open source IOT platform: http://iotgo.iteadstudio.com and API compatible. Which is strange 'cause sonoff itself is locked. With some luck and help, i may be able to get it working with openHAB and more which seems intriguing to some of us who don't want to completely lose stock firmware and still be able to use them with other software.

    1. Not sure what you mean by locked - it's just an ESP-12 - you can easily put other software on it - like mine or others. The stock firmware is neither here nor there and I'm sure they'll make it available if you want to re-flash.

      1. I meant that it is software locked to it's app, E-welink. Sure, one can easily reflash it with other firmware and be done. But you cannot reconfigure it with another MQTT server or integrate it with existing infrastructure without touching hardware and warranty. Not everyone's have the skills or technical knowledge to reflash or willing to lose support 🙂 Weird part is, API is already in there, in stock firmware and cloud - its just not exposed. As of writing, I successfully sent commands from my computer to websocket they're using and operate my slamphers without even touching to a single screw on them or stock firmware. That paves the road for openHAB etc binding without firmware change. BTW, there's a RGBW led light bulb that i came across that also uses ESP8266 with rx tx 3v3 and gnd headers exposed on its board.

        1. I should not worry about warranty... the price of Sonoffs you could never justify sending them back for replacement - the postal charges at this end would prohibit that. I took a good look at Openhab some time ago and that alone was enough to make me want to develop something else 🙂 I'm increasingly finding Imperihome to be my own way forward coupled to simple Node-Red glue code.

          RGB bulbs - always interested in that though most I've seen are not bright enough to warrant the horrendous price. Somewhat more messy I usually stick with strips of serial WS2812B LEDs.

          1. What are the advantages of Imprihome/node-red over home assistant?

            Do you have a good source for the serial led strips?

  51. Ok, so LED strips- not really - just EBAY - get best price.

    Imperihome/Node-Red - Imperihome is merely the end App for Android/IOS - the controls if you like. By bringing everything into Node-Red you are not limited to someone elses rules - you can make any rules you like - and interface to any gadget or protocol.

  52. Hi all. First - this is great discussion. I have got my own Sonoff and I will try to connect it to my small Domoticz server (I'm just starting with home automation). As I understand, I have to use EasyESP soft to do this and It will not support small switch like in original firmware to toggle a relay/light 🙁
    But my question is about idea how to use Sonoff as a wall switch?
    I would like to use regular switches (like this: http://www.homedepot.com/p/Leviton-Decora-15-Amp-Single-Pole-AC-Quiet-Switch-White-R72-05601-2WS/100058788) that I already have installed at home.

    My idea is to add to those switches something like spring to make it automatically returned to off position. Second issue is to put sonoff (without a case) to a electric box together with the switch (I don't know if it is not to big). Connect 110V wires to the sonoff and original light switch as a low voltage switch to sonoff (to GPIO or instead of a current micro switch).
    It could be really cheap solution to change whole home to smart home installation.

    But question is if it's possible. I couldn't find any idea on the internet how to remodel standard wall switch to make it spring return (is it possible to buy switch like this?) and do the rest of things. Or maybe it is impossible (to big etc.) or I was trying to find it not to deeply.

    Do you have any experience with this or any idea how to do this?

    Best regards,
    Arcos

    1. Arcos,

      I have put a bare Sonoff TH (no case) in a standard (US) single gang electrical box with the led and button poking through the cover plate. Not an ideal arrangement but it does work. The button is configured to toggle the relay and send the updated state back to Node Red via MQTT. Inspired by your desire to use a standard on/off wall light switch I have modified my software to use the available GPIO 14 connected to a switch. Still not ideal as the relay state is determined by the last request. Node Red always knows the relay state so it is possible it can turn the light back on if it doesn't like the state set by the local switch. In most cases I can see the light from the local switch so if the switch is on but the light is off I can simply cycle the switch off/on to turn it on.

      In both cases the problem is fitting things in the box. Most of my lights are wired with #14 solid wire. It is too big and stiff to directly connect to the Sonoff so I use #16 stranded "pig tails".

      John

  53. Hi everybody, sorry for my awful english...but I've a problem with Sonoff Wifi

    I'm using that switch for air conditioning on my bedroom and I found out that in case of a blackout the switch loses all settings.

    On eWeLink it is no longer possible to control a switch because it does not come back online and I must do all settings as the first time.

    Some of you have had the same problem? you have ever had a test of this kind? Is there a solution?

    1. My software retains the state of the output - I think the original Sonoff software does not. Others have written their own - I don't know if they have retained the state - but if you're writing software it is trivial to store a structure in FLASH as the routines are already written.

      1. thanks for your answer, Peter... so you think there's no other possibility if I'm not able to write software...

        there is someone else who has had this problem?

  54. Hi, Is it possible to modify a Sonoff to monitor through the app, the status of a switches contacts? I'd like to monitor remotely whether a door is closed or not. Any help in doing this would be appreciated, I'm not familiar with coding whatsoever however the electronics side wouldnt be a problem.

    1. Well using my software you can certainly read the status of the output - but as you already set the status that's not a lot of help. There is no way to know the status of the ACTUAL contacts without more electronics of course.

      1. Thanks peter for your reply. I have a Sonoff with the Temp/Humidity sensor. I was wondering if its possible through that sensors data line to read whether a logic signal of 5v (or 3.3v) to 0v can be interperated in some way as to indicate the closing of a magnetic door contact. I see that the temp/humidity value is constantly being reported back.

  55. Seems sensible to me.

    Sorry to go right back up the thread but I've ordered 3 of these Sonoffs. When someone said pass the earth through I presume I wire these live and neutral with the earth wire just going round the side joining the earth from the plug before it goes into the sonoff and connecting it with the earth on the other side before it goes into the device?

      1. Thanks Peter. I'm sitting in sunny Spain at the moment where two wires might have made it a bit tidier / easier but we return to the UK soon.

    1. Sure you could do that. I don't think there is an earth connection in the units at all.. and that's fine as I imagine they are thinking of lamps etc, many of which only have 2 wires anyway.

  56. thanks for this guide. all sorted with my sonoffs. one question would be how safe are these things? I can't see any CE mark or any form of accreditation. it works like a dream on a 2 core lamp I've got but should I feel comfortable with the quality?

  57. Hi,

    I have reviewed the Sonoff's schema. What about the relay part? I can't see any snubber circuit to protect it from a inductive load as a motor, several bulbs, or any inductive load.

    What do you think about this ?

    Regards

    1. I could have sworn they had a VDR in there - maybe not. Well, if you're planning an inductive load you can always put your own snubber circuit in. I've powered a small heater no problem.

  58. Thanks for the great write up. Lot's of good info here. Question on the wiring, can this be wired to control a 120v outlet? I have several outlets that I want to setup but sure hate the $$ that it takes to turn those into a zwave outlet.

    1. A Sonoff could easily be made to control an AC outlet - of course you would not want to plug in a major piece of machinery taking several amps - but for general lighting and light duty stuff sure. They are sending me their latest Sonoff devices in the coming weeks and I'll be blogging about them.

      1. Thanks, I saw that it was only 10amps. Want to use them for outside applications. Be able to turn on lights on the deck etc. I do have a pump that I would like to run but I am sure its more than 10amps but will check.

        Do you know what is going to be new with their new models?

  59. Hello, thanks for the posts and guides about the sonoff device, i just started to explore IOT and "smart home appliances". Anyway I just stumbled upon this device : http://www.ebay.nl/itm/ESP8266-WiFi-Relay-V3-1-/302065993872 and thought you would find it interesting.

    The only thing that is tricky, somewhere down the description it states that : "If you want to use the module to 230V power, you must solder the voltage transformer and the fuse itself. Here the risk is yours."

    But I guess this would fit directly into an wall socket. Anyway thanks again for the fine reads.

    1. At first glance it looks fine - but for reasons beyond me to add to the 20 Euros cost, there's another 14 euros post which makes if 34 Euros. I don't think soldering that PCB fuse would be an issue or putting the transformer on - it all looks fine - but it would be nice if the PCB was available. I started all of this because of the cost of DIY IOT kit before we called it IOT.

  60. OK I found it. Thelast hole on 5 holes modification is free (it is GPIO 14 I think...). I would like to ask you hove is status changed ralized in MQTT. Device reports status change or is contacted by mqtt broker in some time interval to get the status? I mean is it push or pull?

  61. Hi, thanks for the great article.

    I haven't started hacking the firmware yet, but I automated my swimming pool pump and pool light with sonoffs, and am using the E-welink app to run it all.

    I've used a TH10 with a temp and humidity sensor to operate the filter pump, adding a 3hp relay to handle the 10A of inductive load the motor draws (I've fried those little blue onboard relays before by getting cocky).

    The pool light is a 400w incandescent, and a standard sonoff handles it just fine.

    So for less than $40, I am controlling a filter pump and a pool light, as well as monitoring the current temp and humidity at the pool.

    Not bad at all, considering a comparable control system from swimming pool manufacturers (such as Jandy or Pentair) cost at least $800 to accomplish nearly the very same thing.

    Overall, Itead Studios seems to put out robust and useful hardware, and I look forward to more from them.

  62. I've had some of the original sonoffs for a while, untouched....

    They have 5 pins above the push switch... I can confirm that the wiring is totally different. Starting from close to the big button it is 3.3V, Serial, Serial, GND.... 13 is the LED (active low), and 12 is the relay.

    I've replaced the flash and have OTA working nicely.

    thanks for the help there!

  63. Anyone tried using any of the Sonoff Touch - Luxury Glass Panel Touch LED Light Switches https://www.itead.cc/sonoff-touch.html or the Sonoff Dual WiFi Wireless Smart Swtich https://www.itead.cc/sonoff-dual.html for controlling multi / gang switches? Except for a few closet light switches most of the light / fan switches in my house are in the 2-5 gang (US) / switch range. Not sure if these will easily fit inside a regular 1-2 gang switch box and utilizing a momentary push button switch in place of the original switch to provide manual on / off device control. If they can be reprogrammed and used in the same way, using the Sonoff Touch switches could do the trick.

    I see the itead.cc site also lists a 4 Channel WiFi Wireless Switch which includes an RF remote and no case, but I don't have an interest in using those remotes and it would be nice if it had a case so insulating bare contacts (in a metal gang box) wouldn't be necessary.

    1. Sorry the pic was larger than I thought and was thinking it was the profile pic! I'll have to register and edit the post if possible.

  64. From further reading in this thread and the "Sonoff TH10 and TH16" thread, I've gathered some good info that answered many of my questions and it looks like Peter plans to do some reviews on some of the models I've mentioned soon.

    Looking forward to reading what he has to say and i'll plan on placing some orders so I can start working with them.

  65. Hello Pete,
    Using your blog I tried flashing my first Sonoff, which didn't work. Turned out my Funduino FTDI programmer - with 3v3/5v switch - outputs 5v no matter what the switch is set to (thanks China!).
    This makes me believe I fried something. With the original eWelink app, everthing still functions, but I cannot enter flash mode. Can I revive the unit by soldering a new Winbond W25Q80BVSSIG IC? Thanks for any help!

  66. I am trying to clear the flash of my sonoff with esptool. When I try to do it I get esptool error: argument --port/-p: expected one argument. Does anyone know what this means?

    Steven

  67. Peter,

    I want to use a Sonoff and MQTT to control my light switches. At the same time, I want to be able to manually toggle the lights using the physical switch.
    1. Can your firmware toggle the relay on the Sonoff when there is a state change on GPIO 14?
    2. Can this be done if the MQTT server is not available? - (If my MQTT gets knocked off the network)

    Thanks

    1. As MQTT is how the whole thing communicates - it would be like removing it's veins. I have never, ever had Mosquitto Broker fail on me in 2 years. The Firmware does not attempt to "do" things - it sends messages out and it reacts to messages coming in. Node-Red (in my case) acts as the controller. If you use node-red-contrib-bigtimer - you can simply inject manual override messages into bigtimer to manually turn stuff on and off. So let's say you set bigtimer to turn the lights on at dusk and off at mignight. Injecting "on" or "off" into the timer will override the automatic settings until the next change of state. Or you can inject "auto" to reset bigtimer to it's auto state.

    2. I'm very interested using GPIO14 to work as the wall switch. This makes the existing wall switch work as a controller for manual operation.

      But I'm worried that it'll have a power surge issue as I have not much knowledge on sonoff.

      Are you successful in the setup you described in the photo? A bit more details of how you connected GPIO14 would be very helpful.

      Thank you very much. Guy.

      1. As long as you don't let mains anywhere near that wall switch there is no reason you can't use the mains switch as an on-off toggle. There is a certain amount of protection on those inputs but I guess you could fit a low voltage vdr at the board end from ground to the input... make sure you've something like a 2k2 pullup to vcc on the pin.

  68. Hi Peter,
    I have tried my best to get my Pi and the all in one script to work. I now get the sonoff to conect but it disconnects soon after. I have tried to follow Peter Oates great videos to connect to the Sonoff as well. Here is a serial output from the sonoff, plus a picture on what node-red is doing.
    Can't autodetect firmware, because proper answer not received (may be unknown firmware).
    Please, reset module or continue.
    MQTT Broker connected
    Device ID is ARPS_000776B7
    MQTT Disconnected
    MQTT connecting
    MQTT Broker connected
    Device ID is ARPS_000776B7
    MQTT Disconnected

  69. Hi Peter, I am having problems with connecting my sonoff to Node-red. Here is the output.Can't autodetect firmware, because proper answer not received (may be unknown firmware).
    Please, reset module or continue.
    MQTT Broker connected
    Device ID is ARPS_000776B7
    MQTT Disconnected
    MQTT connecting
    MQTT Broker connected
    Device ID is ARPS_000776B7
    MQTT Disconnected

    Dusk/dawn will not update to the sonoff too. Debug show no updating.
    Here is a picture of my Node-red setup.

      1. I redid it. But it could be my image as I used home assistant as it made my usbaudio work for me. Can I reinstall via the script to set Mosquitto? I did think about setting up Node-red on a old Tab Acer Iconia. Then turning off my pi's and testing it. By the way thank you and the whole team for doing this software. It has got me back into electronics after a long while.

      2. Just to let you know the all-in-one script is stopping at pushbullet. Now I have been manually doing the script from there. Then rerunning the script to get the last bit in without node-red part. Would this cause the problem?

  70. Here is what I get now after changing mqtt_password. Said there a good youtube channel to learn node-red?

    _STATION mode
    Web page control enabled
    Connected as 10:1:1:26
    MQTT connecting
    MQTT Broker connected
    Device ID is ARPS_000776B7
    -->
    MQTT Disconnected
    MQTT connecting
    MQTT Broker connected
    Device ID is ARPS_000776B7
    -->
    -->
    -->
    -->
    -->
    -->
    -->
    -->
    I must be doing something wrong the update never gets to the Sonoff.

    1. Well, it all looks like it is working - try renaming the units to sensible names (ID) - I normally always do that and I'm wondering if perhaps the automatic underscore in the names has something to do with it...

  71. 1480922678: Client ARPS_000776B7 already connected, closing old connection.
    1480922678: Client ARPS_000776B7 disconnected.
    1480922678: New client connected from 10.1.1.26 as ARPS_000776B7 (c1, k120, u'admin').
    1480922759: New connection from 10.1.1.26 on port 1883.
    1480922759: Client ARPS_000776B7 already connected, closing old connection.
    1480922759: Client ARPS_000776B7 disconnected.
    1480922759: New client connected from 10.1.1.26 as ARPS_000776B7 (c1, k120, u'admin').
    1480922771: Client mqtt_def9a805.210658 disconnected.
    1480922771: New connection from 10.1.1.24 on port 1883.
    1480922771: New client connected from 10.1.1.24 as mqtt_d8ca63c1.2735a (c1, k60, u'admin').
    1480922819: Client mqtt_d8ca63c1.2735a disconnected.
    1480922819: New connection from 10.1.1.24 on port 1883.
    1480922819: New client connected from 10.1.1.24 as mqtt_8a0dcbde.75f238 (c1, k60, u'admin').
    1480922879: Socket error on client ARPS_000776B7, disconnecting.
    1480922882: New connection from 10.1.1.26 on port 1883.
    1480922882: New client connected from 10.1.1.26 as ARPS_000776B7 (c1, k120, u'admin').
    1480923779: New connection from 10.1.1.26 on port 1883.
    1480923779: Client ARPS_000776B7 already connected, closing old connection.
    1480923779: Client ARPS_000776B7 disconnected.
    1480923779: New client connected from 10.1.1.26 as ARPS_000776B7 (c1, k120, u'admin').
    1480923849: New connection from 10.1.1.26 on port 1883.
    1480923849: Client ARPS_000776B7 already connected, closing old connection.
    1480923849: Client ARPS_000776B7 disconnected.
    1480923849: New client connected from 10.1.1.26 as ARPS_000776B7 (c1, k120, u'admin').
    1480923967: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1480925768: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1480927569: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1480927722: Socket error on client ARPS_000776B7, disconnecting.
    1480927723: New connection from 10.1.1.26 on port 1883.
    1480927723: New client connected from 10.1.1.26 as ARPS_000776B7 (c1, k120, u'admin').
    1480929370: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
    1480929619: Client mqtt_8a0dcbde.75f238 disconnected.
    1480929619: New connection from 10.1.1.24 on port 1883.
    1480929619: New client connected from 10.1.1.24 as mqtt_847ca8f2.7b8358 (c1, k60, u'admin').
    1480929676: Client mqtt_847ca8f2.7b8358 disconnected.
    1480929676: New connection from 10.1.1.24 on port 1883.
    1480929676: New client connected from 10.1.1.24 as mqtt_ca4888a0.35b778 (c1, k60, u'admin').
    1480930442: Error in poll: Interrupted system call.
    1480930442: mosquitto version 1.4.9 terminating
    Mosquitto log file from pi.
    /var/log/mosquitto/mosquitto.log

  72. Hi Peter,
    The user name and password work in MQTTspy and pass to the broker and back well. I use wireshark to check the network but can only see the stuff I send from MQTTspy. The sonoff connects to my network but does not send any esplogin information. I can't see your code so I am in the dark what to do next. By the way it connects to the broker. I think I have worked it out does your software have a {mqtt_passwd:"placepasswordhere"} ?

  73. hi , may i ask you something??
    i have a sonoff in the folowing configuration:

    power---->normal switch-------> wifi sonoff------->bulb

    could it be posible to program the sonoof so when i ever switch my "normal switch" off and then on , cuting the power on the sonoff and the reestablishing it, the sonoof toggles the state of the internal relay? i want to do this in order to use both no matter if i switch it of from the smartphone or the normal switch

    thank you

    1. Kind of depends if you are using this stand-alone or part of a home control system - and where you are using my software, some other software or the original software - no-where near enough info here.

  74. Can't help automating just about everything about the house. First year that we've had a WiFi enabled Christmas tree, good man Pete!

    Christmas Tree lights using your Bigtimer and a basic Sonoff to come on at dusk -30 mins with some UI over-rides.

    Thanks for all the highly distracting projects Pete!

    Happy Christmas https://youtu.be/-d5-Npt1BtI

    Garry

    1. Yup and same to you Gary - my little ESP-flashing flame serial RGB candle is by far the most impressive thing hanging out of the window... some day when I can afford to buy a very big 3d Printer (well, any, actually) I will make a point of making Santa frames with special clips for RGB LED!

      1. oh, cool! Did you talk about it somewhere here? Links, or hints on how you did it? thanks 🙂

        oh, a Prusa I3 clone can be bought for about 300€ now... just be sure it has aluminium infrastructure, of if you take an acrylic one, you can buy the conversion kit (look for the hephestos kits)

          1. No. First video WAY too simple - there is no MOVEMENT - check a real candle...

            Same with second video. I reckon serial RGB strip - 3 long - a triangle.. so you get to see it all sides.... top led weakest most of the time... occasionally the light would move UP as well as flickering at the top (but not the bottom). A candle flame is often blue-ish at the bottom - then yellow etc.. these simple 2-3 LED jobs are ok - they work - but they're not fooling anyone.

          1. depends on what prusa... the basic kits you take for 200€ have acrilyc mountings so the structure moves and the Z-axis make "wobble" and you'll have uneven layers... the hephestos version (which i have, bought original BQ kit exactly a year ago) is very stable, on the contrary... sure there are better option, especially today, but i'm good with it, and was very educative to assemble the kit 🙂

  75. Hi Peter,
    I can't use your software so I want to replace it on my sonoff. First problem sonoff will not let me change the software. After updating to other software unit just give me your information when{debug}. Tried Ardiuno IDE and Luauploader. I get this at the start. Can't autodetect firmware, because proper answer not received (may be unknown firmware).
    Please, reset module or continue.
    Now could I replace memory on the board to get your program stuff off. I am not saying this stuff does not work to everyone. It could be memake a mistake.

  76. Hi Peter, I've run into 2 different problems, hope you can help me! 🙂

    1) I flashed a SonOff device with my arduino FTDI cable. I didn't realize that the arduino FTDI cable is a 5V FTDI, but amazaingly, it worked. Right now that Sonoff works but the power regulator in the lower part of the board gets extremely hot (it has even melted the case...) Any idea of what did I broke when y flashed with a 5V FTDI??

    2) I decided that it was not worth the value of the SONOFF to fix it, so I decided to buy 3 more SONOFF devices and a 3.3V FTDI device. But I've repeated the same steps with the 3.3V FTDi and I can re-program correctly the device that heats up (and still heats up obiously), but I'm unable to re-program de 3 new devices, all 3 seems "bricked", the do not have the original firmware anymore (no led flashing at all at powerup) but flashing with arduino IDE always give an error (no response to erase comand" .

    ¿any idea how to force reprograming in these devices?

    Thx on advance
    Alejandro

  77. Problem fixed, it was the router all along. Four week of hell for a router which kept downing the Sonoff off or turning wifi on and off.

      1. Ok, Just lost for paragraphs of what I wrote due to not being connected to the network. Short and dirty talked to you found MQTTspy which is JavaScript look for it by googling it. Connected it to my pi through my old router "NBN ready and two years old lol". Both pi and MQTTSpy passed messagers to the broker and back. Have a video of it on my Youtube talking and monitoring via WireShark. Filter is " tcp.port eq 1883 " Sonoff's showed up on old router. I used Android app "Fling" to see them. Widen the search with Wireshark got this message. Sonoff: IP adress 192.168.2.15 (Tell 224.0.0.1 Who has 192.168.2.15).
        Sonoff's would connect to MQTT Broker then disconnect and continuously repeat this over and over again.
        If you google 224.0.0.1 not much relating to a sonoff. In the end I got smart replaced my router and guess what happened the sonoffs now talk to the pi.
        I still need to check your sonoff software as I have being using a basic script no OTA. By the way how do we get sonoff to put 4 meg chip on as I have only got one to work out of three my eyesight is getting bad and the tracks are to small.

        Anyway thank you Peter, Peter Oakes, and Andreas Spiess for your help and direction. Also please add a edit mod on you blog page just in case I make a mistake.

          1. Not should may the router was on the way out. I will never know unless I put it apart. Peter do you know any going voice activation software? As here in Australia we don't have Amazon Echo or Google home yet. I am using Node-red too.

  78. Hi Pete,

    I'm really happy to have found your blog. This provided me with a great in-road to programming for hardware.

    I am experiencing a minor hiccup with the sonoff. I am trying to use the wifi switch on an existing wall switch while maintaining the physical usefulness of the wall switch.

    It works, however there is a delay between using the physical switch at the wall and the time at which the light comes on of about five seconds.

    I have tried putting digitalwrite code into the void setup () method to speed up the process, but the code does not seem to fire.

    I ended up putting it in the void loop () method. It works there, but there is a delay while waiting for the connection and then the beginning of the loop method.

    Have you encountered this problem and if so how did you solve it?

    1. Remember I see these comments in isolation - including more info as to what software you are using would help. You say "DigitalWrite" so you're not talking about my software - in which case you need to get to the repository of the writer and ask the question there. Something seriously wrong if you are waiting 5 seconds for a response.

      1. You're right, I am not running your software! As you said above in the blog, "I want to control these with MY kit."

        I tracked down the problem; in fact there were two. First, I was setting the relaypin to LOW in the setup method. This should be a reminder to everyone to check your spelling first!

        Second, I put the digitalwrite code in the setup method after a while loop--a blocking call.

        These were silly errors that I should have seen right off the bat, but I was both so giddy that the thing worked and so wrapped up in being afraid there were hardware issues that I skipped over some glaringly obvious mistakes in my code.

        Thanks for taking the time to read and respond, I really appreciate that!

Comments are closed.