Best way to mechanically flip a switch

Hello,

A couple of months ago I got my Arduino Starter Kit and started learning about electronics, and then experimenting with a custom HA system.
Among the things I wanted to automate were the lights and some other switches in my apartment. But being a "software guy" I made a quick test setup and went straight for the software part. Now that I've got that mostly figured out, I'd like to do the hardware part right, and need some help from someone who is a bit more experienced.

My goal is to control the switches and know their current state, but without interfering with normal (manual) use and using specialized switches.

You can see my initial test setup here (- YouTube). It uses a servo with some fixed strings, and I planned to put a custom made switch beneath one of the "teeth". Input to the switch would be the same + wire going into the servo, and output would be a "sensing" wire, so I'd need 4 wires per switch. Using nylon/plastic strings would make it more reliable, but I still don't like it too much.

And here's what I'm aiming for:

  • place wires into walls
  • use SFTP network cables (8 wires per cable)
  • use as few wires as possible
  • use wires as short as possible (7m max, though I've tested the servo with 15m and it works)
  • modify existing switches
  • automation must not interfere with normal operation of the switch
  • add a component to mechanically flip the switch on and off
  • add a component to sense the state of the switch
  • components should be reliable and not malfunction (repairing would be hard because they're going into brick/block and mortar walls)
  • components should be as small as possible, to avoid digging into the walls too much
  • safety - power used for the light switch (220V AC) must not interfere with automation components. This is my major concern. It might be complete nonsense, but I'm mostly worried about induction and the whole thing going up in flames or electrocuting someone. Please advise on this.

You can see the layout and size of the light switch I'm using in the attached photo.
And here are some ideas I've thought of, but I'm unsure if and/or how they can be implemented safely. There's an attached drawing showing every one of them.

  1. Glue the servo at the same place as in the test, but instead of the cross attachment and strings use a gear, pinion and two racks (see Rack and pinion - Wikipedia). Trouble here is making the gears and racks, because they'd have to have just right teeth and be pretty small, and I'm worried about their strength and cost if I go with e.g. 3D printing.

  2. Use a DC motor glued at the same place as in the test with a toothed (conveyor?) belt instead of the strings. The belt would be tight, so manually flipping the switch would turn the motor as well, but unlike the servo it won't break because it's not constrained. I've disassembled one of my micro servos and found a small DC motor inside, approximately 7x12mm, but I'm unsure if I can make it spin both ways, as well as if it's strong enough. Trouble here is making the belt, because it too will have to be both small and strong.

  3. Use 2 solenoids, one on each side of the switch. Trouble with these is they'd have to be pretty small, which means I'd have to make them from scratch, and they'd have to pack enough of a punch with only 5V they're getting.

  4. This is something that might not even be possible, but seems logical to me at the time. Glue a permanent magnet at one end of the switching lever and place an electromagnet on the base beneath it. By controlling the polarity of the electromagnet make the two attract or repel to flip the switch. If this is possible the trouble would be getting magnets small enough and making the attraction/repulsion strong enough to filp the switch.

Thanks in advance for all of your suggestions and comments, I hope I haven't written too much nonsense :wink:

UPDATE 1

After receiving a couple of replies I see that providing some more info would be in order:

The device I'm seeking advice on how to build here is not even close to being my whole project, but just a tiny part of it, which is important and currently troubling me the most. The test setup shown in the video is just an experiment to quickly test driving a switch using an Arduino and my mini command language.

I am aware of the approaches most people take when automating lights, similar switches and even wall sockets, but they aren't applicable or desired in my case. Those include:

  • off-the-shelf switches with built in relays and controllers... (existing solutions, like X10 and similar)
  • other replacement switches (e.g. touch switches combined with relays)
  • relays controlling the mains line to the switch or the appliance. Correct manual operation of the switch is most important, automation should not hinder it in any way. The physical (up and down) state of the switch should unambiguously reflect the on/off state of the appliance
  • using a separate microcontroller setup per switch (way to large and expensive)

So that's why I'm trying to find an alternative. Mechanical is just the one that came to me naturally and I'm trying to find the best solution using it, but I'm willing to do it another way.

UPDATE 2

Correct manual operation of the switch is most important, automation should not hinder it in any way. The physical (visible) state of the switch (up or down) must at all times reflect the on/off state of the appliance. For example, if you see the switch across the room is down then the appliance it's controlling must be OFF. And vice-verse, if the appliance is off then the switch will be down.

More about the project:

My project v1 consists of a Raspberry Pi B reading from and writing to an USB "home" device (Arduino Uno R3) via custom serial command language.
Apart from controlling the "home" device, the RPi is also currently acting as a remote storage, UPnP/DLNA media server and renderer, and Bluetooth speaker, and will be more in the future.
The "home" device v1 I've planned and am building is wired through a MUX Shield to multiple indoor and outdoor sensors (temp, humidity, light, wind/draft, motion, door and window state, switch state), indoor switches (light, water heater, ventilator, door buzzer) and some more. In and v2 I plan on adding some controllers (thermostat, AC unit) and sensors (mailbox full, doorbell camera), and so on...

So, you can see that this is not a novelty project or a toy (I get over those in a couple of days), but something I think would be useful and fun to build, as well as a great learning opportunity.

You must have seen places with one light controlled by two switches? Have your Arduino control a relay as one of those switches. Then it doesn't need to know where the switch is, it just needs to toggle the relay to the other position.

Alternatively, use a relay to control the light and wire the wall switch to any of the Arduino inputs. (Disconnect the wall switch completely from the mains wiring.)

The standard practice with home automation systems is to use a momentary switch (or a center-off momentary rocker switch, along with some electronic circuitry. Sometimes with a relay and sometimes with a dimming circuit.

That way you can activate the electronics remotely, or locally by hitting the momentary wall switch.

Your mechanical solution is going to be a novelty at best. Reliability is going to be pretty poor (at best).

Rather than running wires through the wall, if you REALLY want to procede with the mechanical approach, I'd suggest modifying your gizmo so that it can be mounted to the wall offset from the original switch, with an arm that extends across to do the business. You could include Batteries to make it self sufficient in power and an RF module to receive it's commands to turn on or off.

The whole thing could be controlled by an ATtiny at a low cost. Once the novelty has dissipated, you could then remove it from the wall without too much long term damage.

Thank you for your suggestions!

I see now that I haven't given enough info about my project and what I've seen was being done so far. This "switcher" device I'm asking about is just a building block... So, to make it clearer I've updated the OP with some more info (look for UPDATE 1).

The bottom line is - the switch's main use is manual and must not be interfered with. Any action the automation takes should be immediately reflected by the physical state of the switch (on/off position)

MorganS:
You must have seen places with one light controlled by two switches? Have your Arduino control a relay as one of those switches. Then it doesn't need to know where the switch is, it just needs to toggle the relay to the other position.

Alternatively, use a relay to control the light and wire the wall switch to any of the Arduino inputs. (Disconnect the wall switch completely from the mains wiring.)

I'm aware of this approach, but I want the wall switch to have completely the same behavior as before automating. So automation should act like another person.
Also, If I put a relay in, and e.g. turn the water heater off using it, the switch stays in the same "on" position it was before, which is confusing. There are other scenarios, but this one is enough for me to opt out of a relay-solution.

DVDdoug:
The standard practice with home automation systems is to use a momentary switch (or a center-off momentary rocker switch, along with some electronic circuitry. Sometimes with a relay and sometimes with a dimming circuit.

That way you can activate the electronics remotely, or locally by hitting the momentary wall switch.

If I understood correctly you're suggesting I use the same relay-solution as previously mentioned? Or is the switch you have in mind somehow different from e.g. the one I have in my test setup? Maybe flippable from the circuitry (Googling didn't help much)?

KenF:
Reliability is going to be pretty poor (at best).

And that's why I'm asking how to do it right :slight_smile:

KenF:
Rather than running wires through the wall, if you REALLY want to procede with the mechanical approach, I'd suggest modifying your gizmo so that it can be mounted to the wall offset from the original switch, with an arm that extends across to do the business. You could include Batteries to make it self sufficient in power and an RF module to receive it's commands to turn on or off.

The whole thing could be controlled by an ATtiny at a low cost. Once the novelty has dissipated, you could then remove it from the wall without too much long term damage.

The cables will be there for the sensors anyway, adding more won't be a problem, but I would like to keep the number as small as possible...
I think I saw an example of what you're proposing on YouTube about half a year ago, and I agree, that's a novelty at best, but I'm trying to make something different, alot smaller, cheaper and reliable.
I do understand why you thought I'd be after something like that though, seeing the demo setup. But that was just to illustrate the outcome I want - I tell Arduino to flip the switch and it (almost) instantly gets it done, like a human being walked up to it and pushed it :slight_smile:

Sounds like a useless machine (The link goes to a 19-second youtube video.)

Not that your idea is useless but that's the only other example I know of with both a machine and a human switching the same switch.

The bottom line is - the switch's main use is manual and must not be interfered with. Any action the automation takes should be immediately reflected by the physical state of the switch (on/off position)

You will need a mechanical actuator that is able to operate the switch, then disengage itself from the switch to allow manual operation. Your video shows you somewhat have a setup with the servo that does this. You might develop electronic based switches that operate like latching relays which could be operated manually or electronically.

Greensprings:
So i guess you really are not looking for the best way, just a way to do something very hard for no particular reason, and asking us to go along on you exercize in futility

Dear Sir, I am asking for help and guidance in solving a problem with some constraints and acceptance criteria. Participation is voluntary, so if you are willing and able to help, please do.

MorganS:
Sounds like a useless machine (The link goes to a 19-second youtube video.)

Not that your idea is useless but that's the only other example I know of with both a machine and a human switching the same switch.

That was really useless, but a funny one. Surprisingly it doesn't help to solve this problem at all :wink:

zoomkat:
You will need a mechanical actuator that is able to operate the switch, then disengage itself from the switch to allow manual operation. Your video shows you somewhat have a setup with the servo that does this.

Do you mean something like idea #3

Yes, but that was just something to start with, and not in any way a keeper. The idea #2 I had is kind of an improvement, but I was hoping there was an even better way.

zoomkat:
You might develop electronic based switches that operate like latching relays which could be operated manually or electronically.

Can you give a little more detail on that? Are you proposing a custom, non-mechanical switch (e.g. touch)?
If so, I've thought of that, but I'd need to make or buy around 15 of them, and I can't use them for every appliance I planned, so that's another reason it wouldn't be a solution. It would just reduce the number of applications for the original problem...

Whatever solution you go for, I would advise against one that modifies an existing switch (whether new or otherwise). Mechanically interfacing with one (outside of the switchplate) should be ok.

Why?

Well - unless the laws and regulations in your country are very different - making such a modification or such, without having the appropriate certification done (here in the United States, that would be a UL certification - which is very, very expensive) - should your apartment catch fire, your insurance (among others, perhaps) will blame the fire on the switches (whether or not they were involved may be a different matter - but especially if they were involved) - and deny your claim (and that's just the beginning of your troubles).

Heck - such an issue may still be problematic with simple mechanical interfacing, but if you document everything and have that handy - and it is -only- a mechanical interface, you might have some leverage should such a situation present itself.

The same should be said for any new control cabling running through the walls. Ideally, this cable (considered "low voltage") must be located and routed in a particular manner separate from the "high voltage" mains cabling - check into your local/national wiring codes to find out the particulars. In many cases, also, the cabling needs to be "plenum rated" - basically so that if a fire starts in one area, the cable is designed not to readily burn and transmit the flames to other portions of the structure. Again - check your local laws on this, and your insurance, etc - because if a fire should occur, they will use any possible excuse on the planet to deny your claim.

cr0sh:
Whatever solution you go for, I would advise against one that modifies an existing switch (whether new or otherwise). Mechanically interfacing with one (outside of the switchplate) should be ok. [...]

Thanks for the heads up! AFAIK the regulations here aren't very strict, there are some rules and recommendations of course, but once it's time to install everything I will follow them as well as get an electrician to do it.
The modifications I'd like to make will probably similar to the one shown in the old video, with an exception of being encased, as isolated as possible and made with non-conductive materials (probably plastic).
Currently my concern is if it's safe to have something like a servo, DC or stepper motor operating no further than 3-5cm from the mains wire (230-240V), even if it is isolated and the wire encased in the switch's plastic housing. Should I be worried about it getting fried, or getting the Arduino fried, or maybe even someone who decides to flip the switch?

One related question: I can drive a servo with 3 wires and a DC motor with 2 wires directly from my Uno (or MUX shield), without additional modules/boards, but what about stepper motors?
I've never had them, so I never tried, and I just found these little guys (eBay link) while looking into alternatives, and they look promising :slight_smile: I'm still new to the world of electronic components, so missing the vocabulary for searching effectively... Would be great if there was a manifest somewhere listing them (like e.g. the one for gear types on Wikipedia).

if you look at a three-way switch. about 89 cents at Home Depot, it is simple as pie to install.

you add a relay to that. The relay is installed in the wall switch box and acts as the other half of the circuit.

pretty easy and your wall switch would be totally stock.

I should have mentioned that if you have a 3 way circuit already, you can add a DPDT relay to the circuit and make it work.

On the recent BBC's Royal Institution Christmas lectures the principal demo in one lecture involved about 100 desk lamps in 100 windows of a London office block that behaved like a dot-matrix screen to play tetris. For each lamp they operated the normal in-line switch with a servo and standard servo arm - a lot of servos and a lot of Arduinos. Tetris was slow.

...R

if the ultimate goal is to have the automation part invisible, and also using off the shelf parts, the relay would be a simple choice.

the relay can be placed near the switch and may be able to be done wirelessly.

light switch.PNG

dave-in-nj:
if you look at a three-way switch. about 89 cents at Home Depot, it is simple as pie to install.

you add a relay to that. The relay is installed in the wall switch box and acts as the other half of the circuit.

pretty easy and your wall switch would be totally stock.

I should have mentioned that if you have a 3 way circuit already, you can add a DPDT relay to the circuit and make it work.

Sorry mate, thanks for trying, but that solution is exactly what I don't want :frowning: I'm aware of the many variants of it as well and that it's widely used, but no... You can take a look at the section in the OP under UPDATE 2.

dave-in-nj:
if the ultimate goal is to have the automation part invisible, and also using off the shelf parts, the relay would be a simple choice.

the relay can be placed near the switch and may be able to be done wirelessly.

Actually I prefer building things by myself, but the basic components (e.g. dc motors) I rather get off the shelf.

If you take a closer look at my idea #4 (and it's drawing) in the OP you'll notice that it's a lot like a relay. It's got an electromagnet and attraction(+repulsion) behavior, but instead of closing a switch it pulls in or pushes out a permanent magnet.
I've also thought of just fixating the electromagnet to the top of the switch base and the permanent magnet to the rocking cover (without building a container I drew).
For this one reversing the polarity has to be done through an h-bridge, just like with a DC motor, as I understand, but that shouldn't be a problem. I'm just not sure if the attraction/repulsion will be strong enough to pull in/push away the rocking cover. I guess I'll have to try it out :slight_smile:

mbinic:
Currently my concern is if it's safe to have something like a servo, DC or stepper motor operating no further than 3-5cm from the mains wire (230-240V), even if it is isolated and the wire encased in the switch's plastic housing.

Frankly, I think your arrangement with the servo motor and nylon threads is most elegant and will prove the most practical for your specific requirements.

It actually provides excellent isolation - you can easily provide an extra barrier between the servo and the other wiring. Obviously you would separate the Cat 5 cable from the mains and that should not be a concern.

As to insurance claims - well, they are really not going to know the difference anyway. ;D

As in your demonstration, you get the servo to pull one way or another and return to the central position at which point you shut off the power to it (Need a control transistor to do that, or with the cable, provide switched power separately to all servos in parallel). The only real consideration is whether it is practical to carry the servo signals over the cables, or to provide a MCU module near each (which then means you have to arrange a communication protocol and interfacing).

Solenoids would require substantial current to drive and need to be fairly large. You may note the solenoid versus gear-motor comparison in car door locking mechanisms - they seem to have largely gone for the geared motor. The nice thing about a servo is that is a ready-made and cheap ($2?) implementation, providing your own gear train is otherwise a major undertaking. And nylon thread to connect to the switch should be durable.

Bonus points if you can include one of these (or something similar)...

mbinic:
I want the wall switch to have completely the same behavior as before automating. So automation should act like another person.

if you have a 3-way switch, the position of the switch is uncertain. it can be UP and on and and it can be UP and off.
this would only work if every switch were a single switch.
Since you want the physical state of the switch to represent the switch position, push buttons are also off the table.
seems that your idea of motorizing the switch is the only one that meets your criteria.

Paul__B:
You may note the solenoid versus gear-motor comparison in car door locking mechanisms - they seem to have largely gone for the geared motor.

Oh yeah, central locking actuators. They are pretty darn cheap and they are specifically built for both the human and the machine to operate the same lever.

Here's a link to one I've used in the past: Jaycar Master Door Lock Actuator

In that system the 'master' is the driver's door which has a microswitch inside it to let the system know when you've pushed the lever - there is then a control box which operates the other 3 slave locks. You can buy the set of 4 with the control box for about the same cost as buying two individual actuators.

You can drive them from 12v with just a relay or you can use any motor-control chip which can handle the power. I think the H-bridge (reversing) motor controller is the way to go these days. If you get the kit, maybe you can scavenge the required relays from the control box.