D1 Mini

Posted on March 2nd, 2016

Showing the single result

0 responses to “D1 Mini”

  1. Ola says:

    URL to the power regulator?

  2. […] Read more and get the source code here […]

  3. Evan says:

    Hi Jon,

    I know it was cited as an example, but it seems to me that that software running on the Arduino board is deficient if it only tries the DHCP server once and doesn’t keep doing it until it gets a response. A nitpick, I know, but the hairy-eared programmer in me was twitching. 🙂

    I was also wondering, given you are running most of those board via power over ethernet, is it possible to software control that to trigger a reset instead. Then your watchdogs could just listen to the MQTT and cycle the POE on the corresponding port (as well as report the issue). Just another (probably more complicated) way to attack the problem.

    Great videos.

    E.

    • jon@superhouse.tv says:

      Hi Evan 🙂

      I’ve had a couple of people say that DHCP requests should be attempted indefinitely so the watchdog isn’t needed, which is correct in general. I should have used a better example. It’s fairly easy to put a check in the main loop so that each time around it checks if it has an IP address, checks how long it was since it was last requested, and tries again if the counter has exceeded a retry time.

      However, that means putting a few extra lines of code in the loop, and allocating another couple of bytes to storing a timestamp. When you’re working in a processor with 2.5k of RAM and 16k of flash, sometimes you need every byte you can get just to buffer part of a packet. Every potential error such as a failed DHCP request can be coded around with checks and safeguards and timestamps, but every one of those extra checks grows the code by another few bytes. At some point you can’t just keep adding tests to recover gracefully from every possible failure.

      Yes, centralised power management would be one way to move the watchdog away from the device and put it in a central location. That would work for some devices, but not for some that are remote. I have some devices running on solar, and I’ve had devices physically located 1000km away that I had no physical access to or control over once they shipped to another site, but I needed to make absolutely sure would attempt to recover themselves if something went wrong. I should probably have used something like that as an example.

      One very interesting idea that came up in the YouTube comments was having some code running somewhere that would watch activity on MQTT, and if it failed to see any particular device for a period of time it would log a failure and send an alert. Not quite going as far as actually power cycling the remote device, but very handy to be notified if something is out of the ordinary. I don’t know of anything like that but I’m going to investigate it, and write something if necessary.

      • Evan says:

        Yes, there are probably many situations where those hardware watchdogs are the correct solution in the never ending list of trade-offs. Sorry if I was sounding negative, didn’t mean to be. They are the hardware equivalent of an exception being thrown all the way to the main-entry function restarting the program, I would say. Certainly done that before.

        P.S. How old is your dog? Our Lab is nine and age is just starting to catch up with him (arthritis). Even still, he would never sit still that long if I needed him to.

        • jon@superhouse.tv says:

          Don’t worry about it, you’re not the only person to tell me that it shouldn’t fail hard for something dumb like a lack of DHCP response!

          We think Bonnie is about 5 (maybe going on 6) but we don’t know for sure. We got her from Animal Aid so we only have a best guess of her age at the time she was found. She LOVES attention, so it’s not hard to get her to sit still: all it takes is a pat or a foot against her and she’ll just lie there. Just like a WDT she’ll instantly jump up if you stop paying her attention though, so she was the perfect prop for this video 🙂

  4. Jonathan Davey says:

    Do you have the complete source code with the libraries as i cannot seem to fins all the correct ones to compile it?

  5. alecthegeek says:

    Amazing. I can remember getting very excited reading the review in BYTE about a new “affordable” UNIX workstation back in about 1983 that only cost about as much as my parents house!

    And it would have been less powerful….

  6. treborjm87 says:

    What motion sensor are you using in this video? Orion?

    In later blog, you mentioned a different motion sensor that had a wider “view” of the area that you were monitoring.

    I’m really inspired by what you are doing with your house.

    I’m running OpenHAB with ESP8266’s, but want to use the motion sensors to automate the lights and fans in the house.

    Thanks!

    Rob

  7. […] you have been reading our blog over the last few months you have probably read about the awesome Arduino homebrew controller or the Arduino cocktail maker. After writing about these projects we thought that it was only fair […]

  8. Qtronik says:

    Well now the problem is how to hook an human/physical switch for sending command to that sonoff or directly… more in/output available inside?

    I’ll definitively buy some but I’ll need a wall “esp” switch too!

    Tank you! This one help me ALOT in my reverse ingineering!
    Love your research.

    • jon@superhouse.tv says:

      The mode button can also be used as an input, if you want to control it directly from the Sonoff. It’s connected to GPIO0, so if you hold it down during startup it goes into a mode waiting for a new program. But you can also check the button position in your sketch, and use it to toggle the output on or off each time it’s pressed.

      • Jean-Christophe Duperron says:

        Received on basic sonoff and testing it with is own cloud eWeLink… really cool! But still want to control it with my openhab and MQTT Protocol (“homie” is a wonderfully well made arduino helper for that…).

        And now I think I’ll be the first to “wire” extend the mechanical button through an “surfacetouch” switch on the wall… I’ll need alot of a research…

        Of course I can just make my own esp8266 wall switch but It will depends on my wifi… again… but now I think of it… independent wifiWallSwitch will be awesome for modifyable Scene!

        Whoa whole lotta questions here!

  9. Kristof says:

    Hi,

    The github links don’t seam to work, i found the correct ones seam to be :
    https://github.com/SuperHouse/BasicOTABlink
    and
    https://github.com/SuperHouse/BasicOTARelay

    (without tv in the end)

  10. greenembrace says:

    Hi it would be beneficial to add a fuse somehow, It worries me shoving things in walls etc. you could use temp. sensor but no point knowing its overheating if your away on holidays.
    daniel

  11. daniel smith says:

    Hi,

    What would be the best way to add a fuse, if the power supply overheats or faults for some reason having devices like this could be a fire disaster. you could monitor is temperature but if your away that’s not going to be much help.

    I think I sent this twice sorry.
    kind regards Daniel

    • jon@superhouse.tv says:

      Yes, good point, safety is very important for any mains-voltage project. Here in Australia all power circuits are required to have a circuit breaker, which is pretty much a universal rule anywhere around the world. So there should already be some level of protection. You could also add a fuse in line with the Sonoff yourself if you wanted to, probably at a lower rating than the fuse on the whole circuit since the circuit provides power to many devices in your house. Please get advice from a local electrician first before you do anything like this, because regulations are different for each country and I want to make sure you do it safely!

  12. Wayne says:

    Brilliant project. You mentioned that the pairing button could be used as another input, to act like a manual on/off switch? I am a bit weak on the coding side so could suggest how I could update the project files to reflect this?
    And how you are planning to Pat the Dog’ with this one?

    Again awesome project….

    • jon@superhouse.tv says:

      Thanks Wayne 🙂

      Yes, the pairing button could be used as a manual on/off switch by changing the code to detect when it’s pressed. I’m working on a follow-up video with more advanced Sonoff tricks, such as replacing the flash memory chip and using more advanced firmware. I’ll also cover how to use the built-in button, and how to connect an external button so you can control the Sonoff manually from a wall plate.

  13. Richard Malcolm-Smith says:

    I just got a cheap NVR that I can connect to my DVRs over the lan – were about $35 or so from aliexpress and no HDD needed to just view cameras. I have some cheapo wireless mice on them for when I need to fiddle with them.

    It looks like the UI is the same as the generic “h264” brand one I got that is well known for being a sieve for security, so dont go portfowarding it from the internet either.

  14. Ed Darby says:

    Thanks for the information Jon, I’m a long time follower of all you projects 🙂

    I had just made an ESP based relay but wasn’t too keen on connecting it to the mains!

    This looks like the perfect piece of kit.

    Thanks once again and keep up the good work!

    Ed

  15. mcmurphyja says:

    Thanks for all your work and willingness to share your experience with the community. I have 10 of these devices that I’m messing around with using arendst’s code. I am very interested in your last post regarding connecting an external switch. I’m also working on connecting a momentary switch with the led backlight to the board. I don’t think that it is the same one that you used for your light switches, but it is very similar.

    I look forward to your next video.

    James

  16. Nermin says:

    I’ve got problem with my sonoff. When i pair it with my phone, it says ” device belongs to other user”.
    Does anyone knows what’s the problem ?

  17. Electrikki says:

    Nice tutorial, thanks for that!
    Did you make progress on connecting the external switch? I’m thinking about this as well.
    I’m mainly interested in if the low voltage from the Sonoff would be enough for the common wall switches (as they would normally not switch these low currents) and, off course, safety.

  18. […] SuperHouseTV #14: Ambient tile using Arduino, ESP8266, and NeoPixel compatible LEDs […]

  19. wayne.carroll says:

    You talked about modifying the code so that the button could be used as an on/off script.

    Were you still going to do this?

    • mike says:

      I’m also waiting for this tutorial. I think its cool to have it as a working toggle switch.

    • jon@superhouse.tv says:

      Yes, I have all the parts now to film another Sonoff episode talking about using external switches and other variations to the basic setup. I’m finishing an episode about electric window mechanisms right now, which is nearly done.

  20. mcmurphyja says:

    That is great news. I was going to share how I got mine working with arendst’s sketch and an LED momentary switch, but it would be better illustrated in one of your videos.

  21. Alru Waldeck says:

    Hi, what an awesome find! Thanks for sharing! Your videos have always inspired!

  22. MrArmsDeal says:

    Hi Jon,
    Great video.
    I’ve been playing about with the ESP-01 for some time now and have built my own version of what the Sonoff module does.
    The Sonoff beats mine hands-down as it’s much more compact and totally self-contained (and cheaper than the cost of all of my individual components). I’ve just taken delivery of 2 Sonoff units and have set to and installed the Arduino IDE version of the O/S.
    I just have one question regarding which pin of the Sonoff/ESP8266 controls the relay. On my ESP-01 I manipulate the GPIO2 to switch my relay on and off.
    I’ve had a look at your sketch ‘BasicOTARelay’ and it would appear to be Pin 12 that activates the relay on the Sonoff board. Is that correct?
    I loaded my own sketch onto the Sonoff and all looks good. I can talk to it via a web browser and the serial output reports correctly. I can’t test it fully until I apply mains voltage but just need to be sure about pin12 first.
    Thanks once again for such a great article.

  23. Take a look at Blue Iris. Much better option than any DVR I have come across. Easy to integrate into web apps etc as well to become part of the general home automation ecosystem.

  24. treborjm87 says:

    @Jon

    Have you tried this on the Sonoff Dual? It’s a little different on the inside. I’ve also seen some traffic that is saying that the Dual has two processors???

    • Jonathan says:

      I’ve just received a Dual so I’ll have a look inside. From what I’ve read, the Dual has a different pin connected to the button so you need to use a jumper wire across specific parts of the PCB to put it into bootloader mode. I haven’t tried that myself yet though.

  25. […] They come with their own software on them which is cloud based but you can upload Sketches via the Ardino software just like you would with an Arduino. So I have a sketch written by Jonathan Oxer who runs the Youtube Channel SuperHouse and also Director at Freetronics. http://www.superhouse.tv/17-home-automation-control-with-sonoff-arduino-openhab-and-mqtt/ […]

  26. treborjm87 says:

    @Jon

    So, the itead forum has had some discussion about the Dual… http://support.iteadstudio.com/support/discussions/topics/11000006870/page/1?url_locale=

    At this point the only thing that I have been able to do is upload to the device. Jumping Pin 15 to ground indeed puts the ESP into program mode.

    Where I am confused is how they are actually talking to the Silicon Labs F330. The relays appear to be controlled by this secondary MCU.

    Looking forward to hearing what you decide to do with this device.

    treborjm87

  27. Ronald G says:

    I enjoyed your You Tube video on Sonoff switches. I too have been playing with this model and a new model issued by Sonoff that is packaged with a male plug on the back and female socket on the front. I have reprogrammed them with aRest ported to arduino by Marco Schwartz. They now host a web page on my home network and do not talk to any cloud servers.

  28. Andrew Johnson says:

    Great to find this project! I had been trying to build MQTT units for power switching out of ESP12s so having a cheap starting point that is CE certified was a great start.

    I’m trying to avoid bricking the Sonoff Dual that i’ve started with, and have got as far as setting up the Arduino IDE with ESP8266 libraries, but don’t seem to be able to find advised board choice/Arduino IDE settings for this.

    To complicate things I’m wanting to add OTA support. There’s some useful stuff in http://support.iteadstudio.com/support/discussions/topics/11000006870/page/1 where there’s an image of the point to attach the jumper that’s grounded to get the Dual into programming mode.

    So guess what I’m asking is, has anyone been reprogramming the Dual, and if so could they share their Arduino IDE board settings?

  29. You inspired me to buy a couple of these things. I took your sketch and added a couple features that I like. Hope others will too 😉

    https://github.com/PepijnVisser/Sonoff/blob/master/Sonoff_1_0_2.ino

  30. Have set this up and it is working really well.
    Where I am a little stuck in OTA updating from a different network segment. My WiFi and Wired networks run on different subnets, so in order to update I need to put my PC on the Wireless subnet for it to come up in the Network Ports list.

    Is there a way you are aware of I can scan the Wireless subnet from the Wired subnet?
    No amount of googling has pointed me anywhere near the right direction.

  31. Mark says:

    The Duals has 12 jumper pins instead of 5. wich one do we need to upload the sketch?
    On the above forum there is a example with mqtt. its not directly talking to the gpio pins. but for me that is ok. I will use them as replacement for my KaKu switches.

    • Mark says:

      The single port is working fine. is there nobody using the dual ones?
      didn’t had much trouble finding the example code. but can’t upload it.

  32. JT says:

    Sorry if this is a stupid question but i’m really new to arduino. In regards to the relay code, both the payloads are 0. Should the first one be a 1?

  33. JT says:

    oh, should I change 49 to 1 and 48 to 0?

  34. JT says:

    of forget my last comments got it to work fine. that’s if my comments ever come out of moderation…….

  35. JT says:

    Just out of interest, do you have to define the clientid in the sketch? Can I remove this? If so what lines in total do I need to remove?

    • Jonathan says:

      Yes, the client needs to supply a client ID to the MQTT broker. That’s how the broker can tell different clients apart, and know which clients have received which messages. It probably depends on the broker, but I’ve found that with Mosquitto it doesn’t like having multiple clients with the same ID. It does wierd things like only send messages to one of the clients, and the other client never sees it. The good thing is that there’s nothing magic about the client ID: it can be anything, it just has to be unique. So you can use the end of the MAC address of the node to generate the client ID automatically, for example. That way your sketch can be the same in each node, and they all end up with unique IDs.

      • JT says:

        Thanks for the reply Jon. I used your sketch to flash the sonoff then created a homekit accessory.js file to control it (via HAP-NodeJS on my pi3) but for the life of me couldn’t get it to work.

        I could control it via manual commands in mosquitto but the commands via the home app/siri wouldn’t turn it on. I then looked at the topic via mosquitto_sub -v -t ‘#’ and the “1” and “0” commands were both coming up when doing via home app and mosquitto but only mosquitto was actually turning it on. I was stumped.

        I initially thought the client id in the sketch needed to be the same as the client id in the accessory.js file. But decided to change it in the accessory.js to something different and hey presto, it worked!

  36. […] To learn about how to install new firmware, see SuperHouseTV Episode #17: Home automation control with Sonoff, Arduino, MQTT, and OpenHAB. […]

  37. Jean-Christophe Duperron says:

    Woah! I extremely like your post!
    All the information’s and ideas that was missing from somewhere else!
    Continue your great work!

    And I’m exited to work on ways to embed toggle switch in firmware with states. You have an starting exemple?

  38. alecthgeek says:

    So I got my PocketCHIP. Didn’t like the lack of security so I’ve created a setup script that also installs the packages above.

    https://gist.github.com/alecthegeek/434325b6ea261ba84499f4966795073e

    However people should copy and modify it to suite. I wrote to reflect my own needs

    • Jonathan says:

      Nice work, Alec! Thanks for posting this. I’ll update the page to add a link to it, so people who don’t read the comments will see it.

  39. PaulG says:

    Great video! Very instructive and your enthusiasm is infectious.
    Question though, re: housing in IP rated boxes (nice explanation btw).

    How much of a negative effect does that housing have on WiFi range of the ESP8266?

    nb Using Chrome 55. no input boxes appear for this form.

    • Jonathan says:

      Thanks Paul 🙂

      That’s a really interesting question about the box reducing WiFi range. My initial reaction was “no, of course not, plastic doesn’t absorb WiFi signals” but then I stopped to think about it a bit more and realised that it *may* have some effect. Industrial cases like the one I used are usually very thick and heavy, much thicker than the plastic on a simple consumer product, and depending on the specific plastic it may contain material that attenuates a 2.4GHz signal. Not likely, but possible. One interesting idea I’ve heard is that if you want check if a specific material will attenuate a WiFi signal, try putting it in a microwave oven for a few seconds and see if it gets hot. If it does, it contains material that absorbs the same frequencies as 802.11b/g etc use. If it doesn’t get hot, the radiation is passing straight through unimpeded. I’ve never tried that myself but I’m tempted to put a box in the microwave just to see what happens. IMPORTANT: make sure there are no captive nuts or other metal parts in the box before you microwave it!

  40. Rolf Marthin Nilsen says:

    Have you taken a look at “Homie” ?

    Homie is a lightweight MQTT convention for the IoT.

    https://github.com/marvinroger/homie

    This is a cool framework. there is also a OTA managment server for it at : https://github.com/jpmens/homie-ota/

    • Jonathan says:

      Yes, I’ve looked at Homie in the past, and I quite like it. I think it’s important to have some sort of structure to MQTT topics, otherwise things get out of control very quickly. When I started using MQTT about 5 years ago I did the usual thing of using random topics out of convenience. It’s easy to do that, but before long you won’t remember what is being published where. I keep a spreadsheet of topics but even that can end up out of sync with reality. Since I’ve been using Theo Arends’s firmware on Sonoffs I’ve been inclined to use his topic structure, just because it’s how the firmware works and it’s easier than maintaining a forked version of his code. His structure is different to Homie: personally I think the Homie structure is better than Theo’s structure because it slices the topics in a different way, with everything oriented around devices rather than message types, but that’s totally a personal opinion. Both ways are “right” if they make sense, and Theo’s structure makes enough sense to me that I’m very happy to use it.

  41. Can you kindly post details of the waterproof box you used?

  42. carlos says:

    Great video, Jonathan. Please keep them coming.

    I found these Windbond chips on ebay but the lower most number listed on the chip does not match your image. Will this matter?

    Here is the link: http://www.ebay.com/itm/10Pcs-WINBOND-W25Q32FVSSIG-W25Q32FVSIG-25Q32FVSIG-SOP-8-IC-Chips-FLASH-BS1-/262478524681?hash=item3d1cf07109:g:LmMAAOSw9eVXWwLa

    Thanks,

    C

  43. Grant says:

    Just wanted to say thanks for a quality post. You are so right, safety is forgotten all to often. Thanks for demonstrating how safety is part of quality.

  44. Dwalt says:

    I am confused by two topics in this episode, first you suggest and demonstrate replacing the flash chip to allow OTA. Later, you cover TASMOTA which incorporates OTA using the existing Sonoff memory. Did i miss something along the way? Is the existing memory sufficient for TASMOTA version of OTA or does it require a replacement chip?

    • Jonathan says:

      TASMOTA fits in the factory-supplied flash memory, so there’s no need to upgrade if you use it. However, many other people have run out of space on the Sonoff when writing their own firmware. If you use TASMOTA, you don’t have to bother with the memory upgrade 🙂

  45. Ed Darby says:

    Great video as ever Jonathan 🙂

    I was running a Domoticz setup before I found out about the Sonoff (via you)

    The ESP Easy firmware works really well with the Sonoff and Domoticz has a built in MQTT broker.

    http://www.letscontrolit.com/wiki/index.php/ESPEasy

  46. Mick W says:

    Love your videos Jon!
    Do you know if these devices are approved for install into homes in Australia ? I have a couple Belkin products but they are quite expensive. Getting the sparky to put some of these in would be a lot cheaper and very customisable.

    Cheers mate,
    Mick.

  47. Bogdan says:

    Thank you! Really nice video
    Will really like to see your opinion on the Sonoff Touch too

  48. JT says:

    Help needed:

    I’ve setup a homekit fan accessory using a raspberry pi, HAP-NodeJS, MQTT and a sonoff.

    It works fine but the one problem i’ve got with it is the status on the home app not showing correctly. When I turn the fan accessory ON the status in the home app my iOS device is correct and shows it’s ON.

    BUT if I leave it on for a while then go back into the home app is shows it’s OFF even though the accessory is still ON???

    I switch it ON then OFF again and it turns OFF.

    I used this code here for the .js file.

    https://github.com/jat80/ESP8266/blob/master/Home%20Automation/Part%208/relayLight_accessory.js

    But modified a few lines to make it look like a fan accessory.
    I don’t really have any experience with javascript (or coding in general for that matter) so don’t know if there is something else in the code that could be the problem with the status not showing correctly.

    Any help would be appreciated.

    Thanks!

    • Jonathan Oxer says:

      Sorry, I haven’t used Homekit so I don’t think I can help with that. Perhaps someone else has some insight?

      • JT says:

        No problem. Thanks anyway.

        I’ve managed to fix the Slampher sonoff problem with the info on Peter Scargill’s website. Had to switch a zero ohm resistor over so you can put it into programming mode. After that I flashed it the same way as the sonoff.

  49. Jon Archer says:

    Hi Jon,

    Always look forward to your vids, especially the MQTT/ESP related ones. I had bought a Sonoff a while ago to tinker with but haven’t really done much with it. I got quite excited when I saw the touch on this video and nearly bought it. I say nearly because when read the blurb i noticed a neutral wire is required and unfortunately, as with most standard wired light switches, there are no neutral feeds anywhere near any of my switches.

    Thanks again for all your content!

    Cheers
    Jon

  50. JT says:

    Help needed:

    I’ve setup a homekit fan accessory using a raspberry pi, HAP-NodeJS, MQTT and a sonoff.

    It works fine but the one problem i’ve got with it is the status on the home app not showing correctly. When I turn the fan accessory ON the status in the home app my iOS device is correct and shows it’s ON.

    BUT if I leave it on for a while then go back into the home app is shows it’s OFF even though the accessory is still ON???

    I switch it ON then OFF again and it turns OFF.

    I used this code here for the .js file.

    https://github.com/jat80/ESP8266/blob/master/Home%20Automation/Part%208/relayLight_accessory.js

    But modified a few lines to make it look like a fan accessory.
    I don’t really have any experience with javascript (or coding in general for that matter) so don’t know if there is something else in the code that could be the problem with the status not showing correctly.

    Any help would be appreciated.

    Thanks!

  51. JT says:

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

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

    Any idea what is wrong?

    • Mark says:

      JT,

      Got the same error about espcomm
      This mean the device isn’t in programming mode.
      press and hold the button before connecting power. after this hold it for a few seconds. now try again.
      After this when using the serial monitor don’t forget to set it to 115200 baud

  52. JT says:

    also any help on my previous post would be awesome as well. Thanks.

  53. spartacus says:

    Is it possible to read state of switch?

  54. DAVID AUSTIN says:

    Nice videos on Youtube. Could you please leave links to the items you use for the things you build.
    The linked items above fail.
    Thanks
    Dave

  55. stratrider says:

    I have tried in multiple different ways but cannot get the OTARelay.ino file to compile. When trying it in Linux I get the following error.
    /home/charles/Downloads/BasicOTARelay-master/BasicOTARelay/BasicOTARelay.ino:14:26: fatal error: PubSubClient.h: No such file or directory
    #include
    ^
    compilation terminated.
    Using library ESP8266WiFi at version 1.0 in folder: /root/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266WiFi
    Using library ESP8266mDNS in folder: /root/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ESP8266mDNS (legacy)
    Using library ArduinoOTA at version 1.0 in folder: /root/.arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/ArduinoOTA
    exit status 1
    Error compiling for board Generic ESP8266 Module.

    I also tried it in Windows but got similar errors complaining about missing directories or files. I was able to successfully upload the blink ino.

    Thanks

  56. Lox says:

    Hello Jonathan,

    Thanks for made me do sleepless nights :/ your posts and videos are very interesting and helpfull.
    I’m trying to connect sonoff rf (with temperature sensor and a button) to openhab with tasmota firmware and I almost succeeded thanks to your tips.
    Your knowledge sharing is very appreciated.
    keep it up…

  57. […] Food. Art. Recycle Bin. SuperHouse Automation. […]

  58. Jaromir says:

    Hi,
    Inspired by your video, I loaded TASMOTA 3.9.11 firmware to Sonoff WiFi and Sonoff RF. Everything works great except for the control GPIO14 (both Sonoff)
    Shorting GPIO14 to the GND – no effect. I do this with supply from USB -> RS 3.3V (without connecting to 230V).
    Where to find the problem?
    Thank you!

    • Pawel says:

      I’ve got exactly the same problem. Got simplest Sonoff with stock firmware and this trick doesn’t work for me either

      • Jonathan Oxer says:

        I don’t think the stock firmware (the one supplied by Itead that works with eWeLink) supports the GPIO14 switch trick. It uses GPIO14 for connecting to sensors. To do that trick you’ll need to use firmware that supports it (such as TASMOTA) or write your own.

    • Jonathan Oxer says:

      It sounds like other features are working properly (such as pressing the built-in button to toggle the relay) and it’s just the GPIO14 feature that isn’t working. Is that correct?

      Check in user_config.h around line 111, which should set the SWITCH_MODE value. For a rocker switch (latching) it should be set to TOGGLE. Also, check that you don’t have any I2C features or sensors enabled because that also tries to use GPIO14.

  59. […] It is a Tweet or Post by Jon Oxer from Superhouse.tv (an awesome Home Automation and Electronics Youtube Channel based in Australia). And the Title of the Post is “SuperHouse Vlog #50: The future of SuperHouse“. […]

  60. Dave says:

    Hi
    This is perfect! The modules look perfect for running light switches, retaining local control and being able to update OpenHAB with state changes. The only wrinkle is that, like most UK homes, I have no neutral at my light switches. Given the module itself runs on 3.3v, do you think there’s any chance of running it from batteries? I guess it’s unlikely to last very long on a pair of AAs.

    • Jonathan Oxer says:

      It wouldn’t run for long. That’s a frustrating situation, and I want to do a video about it soon. The very brief summary is that you can locate the Sonoff in the ceiling where the active loops down to the switch, and where neutral should also be available. Then you can use the active loop to drag a control wire pair that links a wall switch to the Sonoff. There are some things to be careful of (such as don’t re-use the existing active loop) which I’ll cover in the video.

      • Dave says:

        Ah I see, that should work for the upstairs lights as I should be able to access the wiring from the loft. Not sure about the downstairs lights as I have huge sheets of chipboard which I’d have to cut holes in for access. Might be doable though. Would PoE be a viable alternative? I suppose if I’m going to run cable, I could just run an extra live/neutral in, although not sure of the legalities of doing so. I really appreciate the efforts you put into this site and the videos! Great inspiration!

  61. Simon Pavert says:

    Would you be comfortable running these in the wall cavity behind a switch? Will they overheat?

    Great write up, I’ve got 6x in use at home now with openhab2. Just started on tinkermans Sonoff SC + neopixel ring. Might be a good one to cover next?

    • Jonathan Oxer says:

      Personally I’d be comfortable putting them in a wall cavity. They don’t seem to run hot so I don’t think there’s any particular fire danger. I used to have an EtherTen powered by PoE inside the wall behind every light switch, and they run quite warm. I think Sonoffs run cooler than EtherTens.

  62. Dennis Aker says:

    Jonathan:
    I flashed a https://www.itead.cc/wiki/Sonoff_4CH with https://github.com/arendst/Sonoff-Tasmota I have been trying to make it work with Home Assistant without success. If you could help with the setup of both the Sonoff firmware and Home Assistant I would appreciate it immensely!! I have not seen information in your You Tubes about Home Assistant so I hope this is not asking to much!! Thanks for the help in advance!!

    • Jonathan Oxer says:

      I haven’t used Home Assistant, sorry. It’s on my list of things to investigate, but right now I can’t be any help with it 🙁

  63. Kim Lindblom says:

    Thanks for the great tutorial!
    I am just getting started in this and am a total beginner.
    Just installed MQTT and Openhab2 on a rapberry pi 3 and will flash my sonoff switches and try to connect them to openhab2.
    Are there any good step by step guides on how to link the sonoff to openhab and setup a UI in the phone?
    The learning curve on Openhab seems quite steep =/

  64. Pablo Nieto Seron says:

    Have you used Broadlink?

    Can you review and use with sonoff?

  65. Bernard Willems says:

    I’ve flashed the sonoff basic with Tasmota and it works great with OpenHAB.
    But if I connect a short wire (about 20 cm) to the GPIO14 and grnd pin, the switch starts to flip so now and then.
    Might the pull-up be inadequate? Or should I add a filter?
    Any suggestions?

  66. Nigel Holland says:

    Hi I have refashed using BasicOTARelay from superhouse
    question is I need to reflash again how do you do that please

    nigel

  67. Bob Cunningham says:

    I also don’t like to leave remote internet access to chance. Best to get your own SSL certificate and DNS entry. StartSSL and DuckDNS are great for hobbyists.

  68. Bob Cunningham says:

    And also be sure to have a tight firewall, forwarding only specific protocols on specific ports from specific machines.

  69. Bob Cunningham says:

    Unless the Sonoff (or other gadget) will be outdoors or otherwise exposed to the elements or flooding, a weatherproof box is overkill from both the functional and cost perspectives. Similarly, if the Sonoff is indoors and away from kids, animals and friction/vibration, a regular project box can also be overkill.

    Plus, I have a problem with plastic project boxes. They cracked when I drilled holes in them, or they broke while being mounted, or they snapped when the lid was over-tightened. I’m just too cruel to plastic project boxes.

    Metal boxes work fine, but are often too expensive for the task at hand, EXCEPT when the electronics inside generates significant heat, in which case metal boxes are the only way to get the heat out.

    I believe nice boxes are needed only when the device will be exposed for all the world to see. To me, project boxes are more about appearance than anything else.

    My needs for a sheltered electronics enclosure involve guarding against three things:
    1. Insects entering and frying themselves.
    2. Moisture due to accidental spills/spray, or condensation due to normal day/night temperature cycling when humidity is high.
    3. Incidental contact (not forceful) with the surroundings.

    My solution? A heavy-duty/freezer 1 gallon Ziploc ™ bag, some hot-snot, and some tie-wraps. Total cost is under 25 cents. Wish I could attach a photo, but words will have to do:

    Start with the wire cut (Sonoff unmounted), with lots of slack (1-2 ft).

    Cut slots on each side of the bag about 2″ above the bottom, big enough to admit the wire.

    Feed the wire ends in each side and tie a square knot between the two ends, leaving enough spare wire at each end to attach the Sonoff. Secure the knot with a tie-wrap. This provides strain relief.

    Note: The knot is optional, especially for solid wire or Romex: Just overlap the wires and use 4-5 tie-wraps next to each other to prevent slippage.

    Attach the Sonoff, then put everything into the bag.

    Pull the wires tight, place the strain relief so it is in the middle of the bag, right at the bottom. Mark the cable where it exits each side of the bag.

    Put some hot-snot 1″ inside one of the marks, pucker the bag over it, and cinch it with a tie wrap. Repeat for the other wire. Ensure the bag is under no strain when the two ends of the wire outside the bag are pulled apart.

    Next, close the bag most of the way, suck out the remaining air, then close it completely. This ensures the bag won’t inflate due to temperature or atmospheric pressure changes.

    This makes a functional DIY insect-proof and water-resistant enclosure. It is also trivially easy to open and close – no tools required.

    Of course, this solution looks terrible, so it should be hidden, which again helps ensure it is kept well away from hazards.

    And unlike some higher-end weatherproof electronics enclosures (e.g. Pelican), there is no need to include desiccant or do nitrogen purging to control internal moisture, since the step of removing most of the air also removes nearly all of the condensible moisture.

    This enclosure method is fairly durable when protected from the elements and mechanical abuse. I have freezer bag enclosures that are still pliable after being in my garage rafters for over 5 years, and under my bathroom sink for even longer.

    This is not a rugged solution! If more mechanical protection is needed a $2 “old work” plastic double junction box (“J-box”, with cover) can be used, with the freezer bag used inside if moisture protection is needed. The total cost is still far cheaper than a project box, and still ugly enough to be kept hidden.

  70. dariosm says:

    Hi! I’ve been using sonoff with Tasmota firmware and it is pretty stable so far. The only issue is the random on and off state changes, when a phisical switch is connected as explained in the video (between GPIO14 and GND). This issue doesnt happend when connecting a push button and changing SwitchMode to 3 (pushbutton).
    Is there any way to prevent the switch to randomly trigger? May be a capacitor or a pullup resistor?

    • dariosm says:

      Edit: issue also happens with both switch and push button (Switch modes 0 and 3 respectively). I tried with a phone line wire (shielded and grounded to the metal frame of the lamp where the sonoff module in installed), same results.
      I’m wondering if anyone has experienced this issues and solved it, it is extremely annoying to the point I had to leave out the physical switch until I find the proper way (if there is any) to install it.

    • Jonathan Oxer says:

      That’s interesting. I haven’t seen that problem, but there are probably some things that can help fix it. Firstly, you could add a stronger pull-up. I’d start by putting 10k between the input and 3.3V. This will effectively be in parallel to the existing pull-up on the board.

      Do you know if this happens only when the mechanical switch is open, or closed, or both? Also, how long is the cable to the switch, and does it run directly alongside mains wiring? Try to take data connections across mains cables at right angles, if possible.

      • dariosm says:

        Hi Jonathan, thanks for the answer. The issue happens both in close and open states of the switch.
        Here you have some pictures of the actual work: https://goo.gl/Miyvm5
        For data, I used 15cm of telephone cable (https://goo.gl/q5Mk8E). That was after considering some the discussion taking place here: https://goo.gl/GlQ94k, specifically regarding the use of shielded cables to avoid interferences.
        For the pictures you can tell I tried to place the data cable from pinout header in a 90d angle wrt mains, but also you can check all cables (main input, output and data) come across a single hole in the lamp and that might not be the best idea. Again, as I am using a shielded cable for data, grounded to the metal frame of the lamp, I thought that would be enough, but may be not at all.

        • Jonathan Oxer says:

          Oh, I see, so the cable isn’t even very long! When I first read your comment I assumed that you meant 15 meters, not 15 centimeters, then I saw the photo and realised that the Sonoff is mounted right behind the lamp fitting. That’s such a short piece of cable that I don’t see how it could be a big problem like this. Also, if it happens in both the open and closed states of the switch, I think there’s some other problem happening here. If the switch is closed, the digital input will be pulled to GND really hard through a direct short circuit, so the Sonoff absolutely should not see it change state.

          I’m puzzled about this. Can you see the Sonoff reporting a state change? For example, if it’s publishing its state changes to an MQTT broker, can you watch that topic and see it send a bunch of on / off messages?

          I’d really like to know what’s going on here.

          • dariosm says:

            Hi Jonathan, I decided to re-solder the header pins and replace the external switch, but keeping the shielded wire grounded to the lamp metal frame. It’s been two hours and there are no records of state changes in the logs so I think it was definitely a combination of bad components and amateur mistake.
            Thanks a lot for your kind assistance

          • dariosm says:

            Hi Jonathan, I have to say my previous attempts worked like a charm for 12 hours or so, but today the module triggered itself again, two events in a row. You can see the logs here: http://pastebin.com/JT2PXnBL
            And here is a sample log showing the proper triggers made from Home Assistant (intentional, not self triggered): http://pastebin.com/NRY6qW6j

    • Mike says:

      I had this same issue on 2 out of 7 sonoffs I have. Putting a 10k pull up resistor in fixed the issue for me.

  71. Bennett says:

    Hi Jonathan,
    Thank you for your great video tutorials! About the rocker switch you used in this episode… is it a regular AC main switch? Or a DC switch? If DC, can you suggest one? Preferably, I’m looking for an inexpensive one that might fit into an AC-sized wall plate. Like this:
    http://www.homedepot.com/p/Hampton-Bay-Devon-1-Toggle-Wall-Plate-White-935TWHB/204803145.
    What do you think?
    Cheers!

    • Jonathan Oxer says:

      Thanks Bennett! I just used a regular AC mains switch in the demo, which is massive overkill for this purpose. For mechanical switches there isn’t really any such thing as an “AC switch” or a “DC switch”, it’s just that they are rated for different purposes because of the way AC vs DC behaves when the connection is made or broken between the metal contacts. You’ll commonly see that a switch may be rated for (say) “250V 10A AC, 120V 1A DC”. That means it’s rated to carry a higher voltage and current on AC than on DC. There are multiple reasons for this, but the biggest issue is the way arcing happens. With AC, the arc will self-extinguish 50 or 60 times per second (depending on the mains frequency in your country) but with DC it will sustain the arc for as long as the contacts are near each other. So a high DC current is more likely to weld the contacts closed than a high AC current. Also, the mechanical structure of a switch can be designed in multiple ways, so that either the contacts close and separate slowly / progressively (imagine a typical “slide” switch) or rapidly, snapping open and closed with a spring. Contacts that “snap” open and closed quickly will experience less arcing, so they can handle higher voltages / currents.

      Short answer: any switch at all will be just fine for handling the 3.3V at about 0.002A that the Sonoff needs for a logic input.

      • Bennett says:

        Brilliant! Thank you for the response! I learn a lot from you everyday! I soldered headers onto my first Sonoff last night and tried to flash it using the ‘Blink’ example code, but the feedback from the upload was that it appeared to be out of memory (I forget the exact text). I must’ve done something wrong so I will try again this evening. Happy St. Patty’s!

      • Bennett says:

        Hi Jonathan, one other question. I’m having difficulty connecting to the Sonoff to flash it using a D1 Mini. Is that even possible? Do I need to load software onto the D1 first? Thank you again. Best, Bennett

  72. Petr says:

    Hey guys,
    I wonder if someone can help. I have the Sonoff basic with Tasmota firmware v 4.0.6 installed. I have configured PowerOnState=1, BlinkCount:0, “PowerRetain”:”ON”, etc.

    My problem is that whilst the relay will come on after start, it will never stay on pass 30s and switches off. It does the same if POWER/LIGHT switched on manually. I think I have checked all possible settings, retained flag, etc but can’t fathom it.

    Any help here?

  73. linesguapo says:

    Hi, thanks for the excellent work, I’m thinking how to do multiple firing with a sonoff pcb, I know that if I change the firmware I can do it as you have explained joining GPIO 14 with ground, but I want to find out some. Method to do it with the original firmware, I discovered that joining the two pins that are seen in the image of the Link, relay switches once but I can not get it to switch again (except I press the button) I think it’s because To be a model without RF components is missing, it would be so nice to verify in your SONOFF RF if you can do the complete cycle of the relay by joining more pins (somehow you have to send the commands off and on the RF module).

    http://s2.subirimagenes.com/otros/previo/thump_9710713img0025.jpg

  74. Link to related blog post is ftps instead of https which is a bit strange.

  75. Andy says:

    Hi I have all of my lights and sockets connected back to two metal cabinets containing 20AMP SSR relays mounted on din rails. I’ve also got some 12V din rail transformers to switch the relays. Can the VIN on the relay breakout boards take 12V to switch the relays (I think the relays can take between 3 and 33 volts to switch and probably sink around 30ma. I was hoping to have maybe one or two arduinos per cabinet, with one containing about 34 relays and the other 20 relays. How many of these boards could be powered in this way from one arduino? Also is there any way to manage state change if the arduino restarts. I.e. not turn everything on or off at start up?

    Many thanks

    Andy

  76. James says:

    Are you aware of this repository?

    https://github.com/UnifiedEngineering/T-962-improvements

    Custom firmware for the t-926 that addresses a lot of the problems with it.

  77. […] to use that one board for building different switch configurations.  You can find the video here http://www.superhouse.tv/arduino-light-switches/ .  His other videos on home automation are well worth watching.   The keypads can be made with or […]

  78. Chris Hiscox says:

    Moving On, how to set up a sellable smart home. With so many cloud based units how can a house be sold as smar t when all the tech is really personal and if AI then becomes unlearnt when chnging owners. From hostnames not ip address, to planning a move plent of scope to advise and plan

  79. Manu says:

    Hi,
    I like your boards, it’s a great idea!
    Do you have distributor(s) in Europe for the I/O Breakout Shield? (I didn’t find it on Roboshop).

  80. Hi, firstly I have to say awesome stuff…
    I have been working on my own home automation project on and off for the past 2 years or so using capacitive touch switches php mysql python modbus etc, and well lets just say its a bit messy and prone to connection issues. Seeing your switches and breakout boards has left me in awe and i have found the breakout boards on freetronics but i cant find the switches and breakout boards for the switch end of the setup. Would much appreciate a link to them if you have one. Also would love to see how you setup node-red, openhub, and mosquito, seems much easier than writing all my own code php python scripts to polll th earduino modbus and dump into mysql database then use php to display information and give me control over everything remotely.

    • Jonathan Oxer says:

      Thanks John!

      I haven’t listed the button PCBs, because I made the ones shown in the video several years ago and I can’t easily source those buttons anymore. I’ve just redesigned the PCBs to use a different button that’s easy to find, and I have some of the buttons on order. I’m going to do a whole episode about the light switches themselves, and show how to do different styles. When I have the new boards done I’ll put them up on the site as well.

  81. Willie says:

    Hi Jonathan, I subscribe to a number of home automation channels, butI must commend you, I learn most from your channel. Every video has taught me a bunch of new stuff. Great work.
    Question I have is do you ever publish your sketches or code? I’m not a programmer but is very keen on setting up lights like you explained with the 8266 and the light switch toggle on a GPIO. I can do the first part, the GPIO part has me panicking.
    Great journey you have taken us on! Thanks

    • Jonathan Oxer says:

      Thanks Willie! I’ve just received updated PCBs for my light switches, so over the next couple of days I’ll be recording an episode about how they work. As part of that I’ll touch on the software side again, including how to use toggle switches and regular light switches in place of momentary buttons. Each of my projects has source code published on GitHub where relevant, and linked from the episode page.

  82. Carlos Ladeira says:

    Totally agree with your arguments. I wouldn’t say better.

    I came from the broadcast industry and I have no doubt that reliability in all environments are granted only by wire connections.

    Wifi might be easy and cheaper but I only consider them if I don’t have way/space to run the ethernet cable inside the wall.

  83. Justin Martin says:

    I’d love to hear your thoughts are options for controlling lights with hard wired connections beyond rewiring everything back to the breaker box.