Hackaday Prize Entry: WiFi In Wall Switches

The Internet of Things and Home Automation are the next big thing, even though we’ve had X10 switches and controllers for forty years. Why the sudden interest in home automation? Cheap microcontrollers with WiFi, ZigBee, and Z-wave, apparently. For this Hackaday Prize entry, [Knudt] is building a WiFi switch, meant to be retrofitted into any Euro wall switch.

There are three parts of [Knudt]’s WiFi wall switch, each of them with different requirements. The top layer is the switch itself and a small OLED display. These switches are really two small capacitive switches, which means there’s no reason to go through the work of sourcing a proper mechanical switch. Good thinking, there. The second layer of this contraption is basically an ESP8266, providing all the logic for this wall switch. The bottom layer is a bit more interesting, housing the 110-230V input, with a Triac or relay. This is where the fun, burny stuff happens.

Right now, you can go down to your local home supply store and simply buy a device like this. History has shown that’s a terrible idea. With home automation cloud services shutting down and security vulnerabilities abound, a DIY or Open Source home automation project really is the best idea. That makes [Knudt]’s project a great entry for the Hackaday Prize.

28 thoughts on “Hackaday Prize Entry: WiFi In Wall Switches

  1. It’s odd no-one thinks there’s a market for ready made, open source, hackable IoT devices. Something like this, for example, but with all the documentation and everything needed to re-program it yourself. Same could go for light fittings or all sorts of other things.
    The PITA with this sort of thing in the UK is that the domestic wiring standards mean there’s only a live cable available, so getting power can be an issue.

    1. Sonoff have a range of esp based mains switches which are easily reprogrammable. Their modules might not fit precisely behind a wall socket, but they are cheap and customisable.

    2. The light switch issue in the UK isn’t impossible to overcome (and I don’t mean by rewiring houses), just have to take a slightly different route to get the power: providing you can generate a voltage differential (say by drawing a load at the light fitting) between the live in and ‘switched-live’ out, you can leach some power to supply embedded electronics (think of a battery miser circuit but continually floating on the top 1v of the mains wave)

      1. I do have some chinesium pir sensor that replaces my wall switch, that trickle-feeds low current through the bulb, which seems to play nice enough with my fluorescent and led replacements, so that they dont flicker.

        but i most certainly wouldnt want to replace all my light switches with it, since its not a guarantee that this will play nice with all possible things i might want to connect to it.

        still waiting for the best solution.

        honestly, it should be quite easy to pull a ground wire to the wall switch, if only the wiring splitter boxes into the wall wouldnt be stuck behind years and years of plaster and tape.

        my wallet is not in a mood for a proper electrical and masonry renovation

    1. I have been working on a very similar project recently using a HiLink HLK-PM01 as power supply. The goal of the project was to have a sonoff-like device, with power monitoring (using HLW8012), a SPDT relay to be able to use it with multi-way switches that could fit in my house gang boxes.

      The first version works really well, using the very same gang box, bezel and front plate, only changing the “click” mechanism by a touch sensor:


  2. There are non-cloud off-the-shelf home automation systems other than X10 – Insteon, Z-Wave, etc. They may take a bit of setup, but at least you don’t have as many worries about the company-closing-of-the-week bricking your house.

    1. Hopefully, this switch is meant as a general-purpose WiFi switch. You can choose whether to connect it to your personal server or IFTTT/Blynk/another third-party service. You can even leave it disconnected from the internet by making an isolated WiFi network and using your server as a secure gateway between that and the outside world.

      The solution to scary and insecure IoT is a PINoDT (Private Independent Network of DIY Things).

    1. yup, i got a bunch of these, take out the boards, solder on better connectors and insulate them and shove them behind a light switch, than use the lightswitch as a toggle switch hooked up to the GPIO pins on the board (since its EPS8266 they have a couple pins you can use for GPIO) also google Tasmota for awesome firmware with everything ready to go to make it talk to MQTT, OTA, WEMO Emulation, MDNS and tons of other features.

  3. Security aside, all those applications will call for 5GHz and better standards to solve the crowding problems arising when everything will be networked, from the cats litterbox to kids toy cars: current standards are less than adequate in that context.

  4. The other consideration is phantom load, i.e. how many watts is a house full of wall plates using just sitting there waiting for a command.

    The Clipsal C-Bus system uses a 36V bus on mains rated Cat5 cable to the switch plates, and each switch plate uses ~15mA last time I checked – so, more than half a watt per switch plate, 24/7. A house full of wall plates like that will use more power than a typical domestic refrigerator.

    That makes “smart house” stuff like that a complete nonstarter in off grid households.

    1. Technically…. (I have not seen it actually done) the ESP can use some DTIM power reduction techniques so its current can go down to 15mA, meaning about 45mW. Still, the DC/DC converted in front of it might be not so efficient and draw 0.5W with no load. Add another 0.3 … 0.5W to keep the relay on when your light is on and yes, such a system can end up using a significant chunk of you energy.

      On the other hand, one ca use good quality DC/DC power supplies that end up using <100mW with no load, use a more efficient radio requiring less power than the ESP and replace the relay with a solid state one. This can have a big impact on "a house full of" such switches, but it costs money.

  5. I have oft wondered weather to use a timer-photocell-ir to control a light. The series powered ones won’t work with a load less than now banned fire-bulbs so CFL’s may work or burn out fast. Then comes LED’s with half again as much load, which can approach the current drawn by the controller. Cheapest and greener to just use the LED and leave it on 24/7.

    When you get hit or even emp’ed by a lighting strike there will be a lot of work to do. Consider getting whole house surge protection in the fusebox.

    1. I doubt leaving the light on 24/7 is green. The greenest would be to have a proper way to control it so you don’t waste energy or reduce the life of a lamp. A simple way to do this is to move the control from that switch in the wall which does not have access to proper wires to the lamp fixture where you have all.

  6. I don’t wan’t to be negative, but…
    Home automation and IOT is fun at first but becomes annoying at some point. Whether it is the WAF (wife acceptancy factor) or the fact that you require some stupid device just to turn on/off the lights (instead of hitting that button on the wall, that button that is always on the same place every time, it will never get lost and always works even when internet is down or your wifi password has “suddenly” changed).
    Progress is fun… until the fun wears off and problems start to show.
    Increased power usage, reliability problems, security issues, network requirements and when grandma comes over to watch the kids you’ll have to explain how to turn on the lights because at her place she still has those “dumb” (but oh so reliable) buttons on the walls.
    I do not mention fire hazard, nope, because I do no know the risks involved of this particular device. But what I do know Is that I don’t dare to use an electronic device (made as cheap as possible) connect it 24/7 to the power lines and hide it in the walls so that if something happens to it, you’ll only find out when it is to late. But perhaps in the future these modern devices mounted in walls will have a temperature sensor of some kind and send you an email when they are on fire because that’s how IOT devices solve problems… using software.

    But don’t worry, I guess it’s me, being negative.
    I guess… I’m getting old.

      1. Neah, you are right, a lot of stuff is just hype.

        Here is what i found the most useful in terms of light: secondary light(s) with motion sensor. Always enough light to navigate the room. General recipe: 12V 1…2A adapter (high quality) + some length of led strip. Usually placed on the top of some furniture and bounced on the ceiling. Created nice soft light. Also coupled with low voltage motion sensor(s).

    1. a lot of the WAF is plain old human habits. pavlov was onto something. even moreso, a specific characteristic of habits is that when they fail to accomplish their goal (reward), humans get frustrated, and displeased, and stressed. see charles’ duhigg “power of habit”.

      that is specifically why i want a wall switch drop-in replacement, and not a novel system (there are quite a few candidates for that…)

      the rest is technical solutions. i dont think we will have a shortage of research (both amateur and proffesional) on that topic.

      if only the human psyche would be so easy to reprogram.

    2. This is where the old expensive players (Lutron, Crestron, etc) still have the upper hand – they’re putting a switch by every door. If it’s a retrofit, it’s a switch/dimmer with on/off or scene buttons and wireless connection to the central hub. If it’s a new install, it’s a low-voltage on/off or scene control button panel with centralized dimmer/switch hardware. The important thing is, the lighting controls are still where they have always been; the automation is just that—automation.

      Sure, you have the Option of turning off the lights with a smartphone app when you just don’t feel like getting up off the couch, but it’s not the primary interaction with the system.

      Smart light bulbs and the like are interesting, but little more than a novelty without effective, immediate control where and when you need it. Projects like this are probably more on the right track than a smart light bulb (and admittedly I’ve toyed around with my own designs for them), but you’ve pointed out their fatal flaw: mains voltage is not the place for cheap DIY. I think I’ll pay more for the likes of Lutron who have been building lighting controls for 60 years.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.