Solenoids and Servos for Self Actuated Switches

The new hotness in home automation is WiFi controlled light switches. Sure, we’ve had computer-controlled home lighting for literally forty years with X10 modules, but now we have VC money pouring into hardware, and someone needs to make a buck. A few years ago, [Alex] installed WiFi switches in a few devices in his house and discovered the one downside to the Internet of Light Switches — his light switches didn’t have a satisfying manual override. Instead of cursing the darkness for want of an Internet-connected candle, [Alex] did the only sensible thing. He installed electromagnets, solenoids, and servos behind the light switches in his house.

The exact problem [Alex] is trying to solve here is stateful wall switches. With an Internet-connected lamp socket, the wall switch no longer functions. Being able to turn on a light when your phone is out of charge is something we all take for granted, and the solution is, of course, to have Internet-connected switches.

Being able to read the state of a switch and send some data off to a server is easy. For this, [Alex] used a WeMos D1 mini, a simple ESP8266-based board. The trick here, though, is stateful switches that can toggle themselves on and off. This is a mechanical build, and although self-actuated switches that can flip up and down by computer command exist, they’re horrifically expensive. Instead, [Alex] went the DIY route, first installing electromagnets behind the switches, then moving to solenoids, and finally designing a solution around four cheap hobby servos. The entire confabulation stuffed into a 2-wide electrical box consists of two switches, four hobby servos, the D1 mini, and an Adafruit servo driver board.

The software stack for this entire setup includes a NodeJS server connected to Orvibo Smart Sockets over UDP. Also on this server is a WebSocket server for browser-based clients that want to turn the lights on and off, a FauXMo server to turn the lights on and off via an Amazon Echo via WeMo emulation, and an HTTP server for other clients like [Alex]’ Pebble Watch.

This is, without question, the most baroque method of turning a lamp on and off that we’ve ever seen. Despite this astonishing complexity, [Alex] has something that is also intuitive to use and, to borrow an applhorism, ‘Just Works’. With a setup like this, anyone can flick a switch and turn a lamp on or off over the Internet, or vice-versa. This is the best Home Automation build we’ve ever seen.

You can check out [Alex]’ video demo of his build below, or his GitHub for the entire project here.

53 thoughts on “Solenoids and Servos for Self Actuated Switches

  1. All the smart enabled bulbs ive used will come back on if you manually turn the outlet off and back on. Its a safety feature in case of fire. Similiar to why the hue color bulbs always first come on to white when the outlet switch is turned on.

    I think smart bulbs are a bad idea though. Its better to by the smart on/off switches at the wall to control the bulb.

    1. The problem I want to solve is being able to arbitrarily select which switches activate with lights, which means you can’t rely on only a smart switch hard wired to a certain outlet. I certainly don’t to pull out my phone every time I want to turn on a light, so I think the solution needs to be the combo smart light/smart switch like this (maybe a little less complicated, though)

  2. Urg. I just used the other available GPIO port in the 8244 to read a push button switch that will toggle the switch locally. You can do this on a -01. Much simpler and lower cost a mechanical solution.

    1. And “horifically expensive” read not actually that much electro-mechanical switch already exist too.
      So a rube goldberg hack ?

      2 relay per switch when 1 centrally and some extra levers would have made it a cheaper parts count but fair enough this aint going commerical.

      Want to solve a smart switch problem? Lack of netural at the wall plate.
      Pretty much every switch on the market requires a netural yet millions of houses dont have them across the globe at the switch.

      1. When I built my house over 20 years ago, I tried to make it as future proof as possible and that included having a neutral wire at each switch. Other future proofing was a little less successful with a lot of coax, cat5 (too early for 5e) and audio wires pulled. Any idea for a good use for the coax?

        I like the idea of hobby servos with mechanical switches for the situation when a true bistable or multistate switch is required that maintains its state without power.

        Does anyone have a circuit that pulls power from the live wire when the light is on and stores it for when it is off? I can think of some simple circuits that may work but could have issues with power dissipation or reactive load. Maybe something like an inductively coupled power harvesting approach would work and be safe.

        1. I want to build a custom house in the future, I think it might be worth the money to run conduit to everywhere and up into the attic so its easy to replace that coax with whatever. Wonder if thats “to code”…

          1. Conduit is best but hard to do. If you use rigid conduit, there is a lot of “plumbing” work and flexible conduit tends to snag the wires when pulling. You will need lots of access points where the pipes bend so that they don’t catch on the corners when pulling. Code is generally not an issue as the wires are low voltage but you do need to consider fire regulations. I used some conduit but there was too much wire (over 10,000 feet pulled) to make using conduit for everything practical. I also installed some HDMI cables but there are easier ways to handle audio/video signals now. Wifi is OK but I prefer the security and speed of hard wired Ethernet where devices are at fixed locations.

        2. I was thinking conduit strait up from the wall box into the attic where it can be run however back to the distribution box, the idea being its easy to drop a new type of cable from the attic into the wall box, but now that I work in the tri valley area in california the thought of building a hope is far away :( house/land prices are ridiculous

      2. I actually had that issue myself with a ceiling light. So rather than wiring into the box where the switch is at, I pulled the light fixture and wired a Sonoff basic into it right where I had both wires. Set it to power on by default. If you turn the switch on, the light comes on. If you turn the switch off, the light goes off (of course.) If you leave the switch turned on, you can control the on/off via the phone app, Alexa, etc.

        Simple and no extra parts needed.

  3. Forget IoT, I have OCD and can’t do useful three and four-way switches because UP *must* be ON; otherwise I throw a “does not compute error”.

    This appears to be the solution I need :), but maybe no computers in the mix, keep it siiimple.

  4. Most home wifi routers have a limited number of connections quoted – 30 ish seems to be typical. Seems it would be easy to hit that limit with an ESPxxxx based approach?

    1. I have a completely separate IOT network that uses multiple very cheap AP/routers (GL-Inet) to provide multiple localized wifi sub-networks that connect to the general purpose home network for external access. Network speed is not critical for most IOT applications but you do need to take care in allocating wifi channels to minimize channel overlap with your high speed general purpose network. This is all part of a multi layered IOT network designed for security.

    1. I wish this type of switch were easy to get and not 10x the price of normal domestic switches. With smarter controls, this switch could be used for dimming too – for example, hold the switch up and the light gets brighter, double click up for half bright, etc.

  5. This also addresses a problem I have often encountered with my IOT builds… which is intuitiveness. For example, I use an installation bus system with momentary switches that each have an “UP” and a “DOWN” direction as well as the idle state. I thought it’d be logical to have the “UP” press turn things on and “DOWN” turn things off, but so far, every single visitor trying to operate the lights intuitively only tried to push the switch DOWN and was thus unable to turn on the light without asking for directions :-/

    1. I’ve been looking for switches like that, can you give me a link to where you got them?

      My idea is to have a 3 position switch (not momentary). Positions correspond to On, Remote, Off. i.e. you can hard-override the state of the device by switching to On or Off positions, or, if you return the switch from On or Off to Remote, the device remains in its previous state, but can be altered remotely.

      1. I’d hate sitting in the ol’ easy chair trying to turn the lights on with my phone, only to find that the wall switch was left in the “not remote” position. While I’m all for manual fallback operation, the concept you describe would IMO be more annoying than useful.

        Which switches to use, it hugely depends on your country I’m afraid…

    2. I forget teh exact name of teh switch but some stand alone Lutron switches were just ubtons had a vertical run of small low birghtness LED’s in the middle to show the light level and direction. Enough for indication when in front of it but no more. Hate to say copy the idea, but…

  6. I was in a relatively new mansion in the early 1980’s.
    In the Master Bedroom (I was delivering a large TV) they had a control panel that had an indicator bulb and a switch (momentary?) for every light in/on the house. That way, the owners didn’t have to go to the garage to turn off its light if someone had left it on. It may have had indicators/switches for the garage doors as well.

  7. This is a solution in search of a problem…

    Why not use one of the the many smart switches that rest at a neutral position. (“Up” always turns the switch/device ON, and “Down” always turns it OFF.) Here are some GE ones:
    “Decora” style (Z-Wave, also available as ZigBee/Bluetooth): https://www.amazon.com/dp/B0035YRCR2
    “Standard” switch (Z-Wave, also available as Zigbee/Bluetooth): https://www.amazon.com/dp/B00PYMGOHM
    Add-on switches (3-way/4-way):
    “Decora”: https://www.amazon.com/dp/B00RKJS8MQ
    “Standard”: https://www.amazon.com/dp/B00PYMGYY0

    1. You may be sad when you discover the power consumption of your relay coil, unless it’s the expensive bistable/pulse-relay kind.

      Then again, the idle power consumption of most of these IOT switching devices is pretty bad too.

      1. I have a touch screen room heating thermostat for the heat pump.
        It has a relay for the output and runs for a year on 2 AA batteries.

        The hold current for the relay is probably very low.

  8. I still have a couple of X10 modules from the old days.
    This is just a ‘haha’ funny aside, but I was just thinking use the Clapper with Alexa to spout clapping noises as some sort of bitpunk automated mess. I will never forget how angrily the old lady at the end of the commercial clapped to shut off the light.

  9. I’m impressed by the project but the point of the application eludes me, other than to possibly maintain the status quo where consumption is concerned, before the IOT light bulbs used a lot of electricity, then along came the IOT and LED lamps, the latter was supposed to save some electricity, but now we have IOT LED lamps that use electricity even when they’re turned off.
    The othe thing is, why not just turn the light on with the switch as you enter the room, why does this simple task need a phone?

  10. Just remove the toggle switch and replace it with a momentary switch (which is an input to the control hardware at logic level, not AC line.) In other words, remove the statefulness of the original mechanical toggle switch.

    Ideally, if each switch node has a relay in it switching the AC line, then this pushbutton should *always* work, with high reliability, to toggle the state of the relay. The switch should always work every time, equivalent to a “dumb” switch, if the WiFi AP goes down, or the Internet link goes down, or the cloud service, the MQTT server, or whatever.

    This is what I’ll call the “escalator” design pattern of embedded automation/IoT systems.
    If you turn off an escalator, you can still use it as stairs.

    A single flip-flop can provide the toggle action, for example a simple 74LVC1G74 because this will provide much greater confidence in its state and reliability – compared to a microcontroller and its code. The nQ output can be fed back around to the D input and the “clock” is derived from the pushbutton switch with a little debounce capacitor – hence the system toggles on each button press. The microcontroller can supply S/R inputs to the flip-flop to assert a given state change regardless of the pushbutton switch, but if the microcontroller falls over the system still works. (But then again consideration should be given to the microcontroller getting stuck in a state where nS or nR are held asserted.)

  11. Since I’m remodeling my house and have the walls open, I’m now installing a homebrew lighting control system. All wall switches are momentary on-off-on, connected back to a central panel using low voltage wiring (I used some old four-conductor telephone wire, which allows up to three switches per location). My wife insists on Decora-type switches so that drove the cost up a bit, but I’m mostly using modified Z-Wave “add-on” switches which, at about $19 each, aren’t TOO expensive. Regular Leviton DPDT momentary switches cost upwards of 40 bucks, though I just managed to score a bunch for $30 each.

    The switches are connected to the 16 analog inputs on an Arduino Mega. A 10K pull-up resistor to +5V keeps the input normally high. At the switches, the down (off) switch connects the signal lead directly to ground and the up (on) switch connects the signal lead to ground through another 10K resistor (this is similar to the way the add-on switches normally work, so the mod is easy). So, the states are +5V (neutral), 0V (off), and +2.5V (on). Each switch needs only one signal wire plus a ground that’s common to all switches at that location, rather than separate “on” and “off” leads for each switch. To have multiple switches control a single light (i.e., “3-way”, “4-way”, etc.), simply parallel the inputs to the Arduino.

    The Arduino drives three 16-relay boards that connect back to the lights through 16 AWG 4-conductor in-wall rated speaker cable–thus, three relays for each light location. I’m mostly using 12VDC LED strings, but the wire is rated for 300V so AC lights can be used instead (or in addition). This allows me to select multiple light levels/types at each location using a single switch. One tap up (on) turns on one lamp lead, another tap adds the second, and so on. A tap down (off) turns off all lamp leads. Holding the off position fo a couple of seconds sets a delayed-off timer for the lights–especially useful in my garage. Holding the on position for a few seconds triggers an alarm mode that starts all of the lights in the house flashing in a high-low sequence–might be useful if I ever get confronted by a burglar, or if my elderly mother who lives with me needs to call for help. If one of my interconnected smoke detectors triggers, a different flashing sequence in each room provides a warning plus escape lighting.

    So, each panel controls 16 light locations with up to three lights at each location. Adding another 16 light locations simply means duplicating the control panel and (for whole-house functions) having the Arduinos talk to each other. The central control/junction panel is a large, modified AC “load center” (breaker box) because it’s sturdy and it comes with the high-current rails that I need.

    Mostly I’m using a combination of three LED strings (warm white, warm white, cool white), so I can select eight combinations of brightness and color temperature. It’s not a “real” dimmer (I didn’t want to run noisy high-current PWM pulses all through my house), but it’s adequate for most purposes. The switched high-current 12VDC (or 120VAC–see below) at each location could be used to run something fancier, but so far I haven’t felt the need.

    The 12V lights are run from big-ass switching power supplies. There is a car battery on a maintenance charger that can be manually switched in to run the lights for a while if the power fails–the control circuits always run off that battery. It could switch over automatically, but I don’t get power failures very often so it hasn’t seemed worth the extra circuitry.

    As mentioned, I could (but haven’t yet) also run standard 120VAC lights (LEDs, presumably, so not much power draw) using the same setup. I have an inexpensive 1kW isolation transformer which allows me to connect one side of the AC secondary to the same common used for the 12V lights (don’t try that without an isolation transformer!!!!). This would allow me to use standard remote-control lights (e.g., Philips Hue) in select locations. The 120VAC could, if needed, be always-on, and my wall switches could be connected to a circuit that would control the Hue lights. Thus, I’d have the holy grail of remote control lights with local wall switch control. If needed, the AC lights could be connected to a standard UPS (which wouldn’t be practical if I were using incandescent lights throughout the house, but is no problem with LEDs). I don’t use a UPS to the power supplies for the 12V LEDs, because it would require a huge, expensive one. The car battery is fine for short-term use, and the control circuit automatically switches to the lowest available light level in each room if the power fails (this can be overridden with the wall switches).

    There are more details (like how I handle very-high-current LED strings), but you get the idea.

    1. Interesting concept. I recently hacked up something that may save you some mney on your project:
      I recently modified a standard (non-Decora) 3-way wall switch to operate in momentary (On-Off-On) mode, as an inexpensive replacement for the GE ZWave/Zigbee/Bluetooth “add-on” switches. One diode, two resistors, a bit of insulated wire, and a spring from a ball-point pen was all the hardware required. (As you mentioned, the add-on switches are very simple.) Total cost about $3 including the $2 three-way switch. I plan on attempting the same mod with a Decora-style 3-way switch.

      1. Nice! Maybe it will help someone else if they want to try a project like this. But now, thanks to eBay, I have all the switches I’ll ever need for this project, including spares.

        I suspect your mod will be a lot easier with a Decora switch since there’s so much space under the paddle to work with.

  12. Mechanically how does the switch resolve if a person happend to press the switch (say off) while the servo is still attempting to turn it on? Who wins? But more so, does the atuator break or strip it’s gears?

  13. To quote: “The new hotness in home automation is WiFi controlled light switches.” I hope it’s just a fad. I really don’t want to unlock my phone and open an app just to turn my kitchen light on. I’ve always ask “can my father-in-law figure it out” when looking at automating or adding light controls. This is the guy who has trouble spelling http://WWW...

    Automation and control should be intuitive and unobtrusive. If it isn’t, you’d best consider what it takes to rip it all out just to make the house salable when you’re ready to move out. While the people reading this site would be happy to take it over, it would the vast majority nervous.

  14. Mechanical movement of the switch is not necessary (see below).

    I believe the wall switches must act normally, but also not stop remote control when turned off. Someone not familiar with the house must be able to walk in, look around for a switch, flip it, and get light. The switches must look like the standard or “Decora” switches everyone is used to. Jon Oxer mentioned on his SuperHouseTV YouTube channel that when he changed switches to plates with pushbuttons people acted like they didn’t know what to do to turn the lights on and off.

    So what I would do is wire all the lights in a three-way switch configuration with one additional “hidden” remote control circuit that acted like an additional switch on the three way circuit. Of course this control circuit could be in a switch that replaced one of the existing switches (or the only switch if there’s just one controlling a circuit). But it would work like an additional three way switch. This means mechanical movement of any of the switches is unnecessary. Flipping any switch on the three way circuit would toggle the state of the light, and the remote control circuit could do this as well on command.

    If you needed to be able to see if the light was on through your phone or whatever the control device is, the remote control circuit would have to be able to monitor if the bulb has power. I’m not sure that’s possible with normal three way switch wiring — I’d have to think about that one.

  15. “Den Automation” actually built this product and we will be able to buy it starting in April 2018 from major UK dealers!!! :D

    I’m really looking forward to buy the light switches, plus sockets,… from Den. They function exactly like the switch you describe in this video and they have a bigger range of products available to buy.

    Plus they have Alexa and Google home integration.

    (sorry if I sound a bit commercial but I’m really excited as I was also always hoping someone would built exactly this product)

    https://getden.co.uk

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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