ordinary light switches and arduino, can the coexist?

Hi there i am studying the possibility of use domotics at home. I ve got a relay module, and arduino mega and a ethernet shield, and i have successfully tested how to turn on and off a light bulb, but my question is can i use my prexisting ligt switches because i ve seen that on every tutorial people use push buttons not light switches.



You mean to essentially use them as toggle switches for inputs to the arduino for example?
Yes you can.

Exactly because if i rewire my entire house and can only turn lights using my mobile phone without being able to use fisical buttons might be trouble. For example if a guest ask for using my toilet, and the light can only be turn on and off using my phone would be unpractical lol

And how can i do it do you know any tuttorial for that?



basically: The light switch is longer connected to the power mains. The relay common-normally open contacts will go in series to open/close the 'hot' line to the lights.
The coil + will connect to +5.
The coil - may be connected to Gnd by two parallel circuits - one will be the light switch, the other will be an arduino output. The coil - will also be an input back to the arduino so it can monitor the state of the pin and determine when it has been turned on by the light switch.
Don't forget a diode across the coil - anode on coil-, cathode to coil+.

Here are some relay examples that have 4.5V coils. They all have need higher current amounts to control them, so you'll probably want a buffer/transistor to sink current to pull the coil- low to turn them on.

This article describes a solution to what you're trying to do:

And this is what I was describing.
The light bulb could be the receptacle being controlled also.
The arduino driven relays allows power to flow.
If the light switch turns on the relay, the arduino can sense that.

Thanks Cross and Chagrin i will chek the info out! :wink:

if you want the house to be 'standard'

X10 is your friend

these guys amongst MANY sell such things,
a complete eco system out there,


CrossRoads i think i am going to try your approach, i 've got for example a single relay module like http://dx.com/p/arduino-5v-relay-module-blue-black-121354 so in this case do i need to change anything from the connections? Thanks

No you do not.

Why not use the light switch sorta like a three way switch. It is used to toggle the light, so, up does not mean on. Let the arduino check for state change, of the switch, then toggle the light. this way, you can still control the light from remote, no matter which position the switch is in.

Thanks guys. Jack i would like that, but how can i do that? i mean, i would leave the arduino mega to centralize all relays but how can i use the light switches to toggle the state of the relays?

The Arduino would look for a change of state of the switch. Say the toggle is up and the light is on, then you remotely turn the light off. Someone gets home, they flip the toggle down. The Arduino sees that the switch has changed from its previous state, and it changes the state of the light from off to on.

Only problem I see with that approach is when guests arrive.
Someone runs off to use the bathroom, they hit the switch, if the light does not come on near immediately they hit it again, maybe a couple of times, now your comm's are all messed up. Maybe account for that with a "guest mode" or something.

Debounce. Write it in the software, if someone flips the switch up and down a lot of times, it ignores until they stop.

Jajaja i was thinking a more educating function for the arduino in that case, something like e.g. a nematic hand appears near the switch and slap the guest a couple of times an additionally a voice saying "i got the idea you son ........" but i guess that is not a winner huh?

LOL i want that!!! Crossroads, in your suggested approach i need to recable so that the ordinary switches receive the data from the arduino right?

And this is what I was describing.
The light bulb could be the receptacle being controlled also.
The arduino driven relays allows power to flow.
If the light switch turns on the relay, the arduino can sense that.

Ok testing time!! Remember i have little electronics knowledge, so what value should the resistor must have and what king of resistor, and i guess you also use a transistor, what kind and value should it have?

Thanks CrossRoads

You first - what you using for a relay?
2N2222A and 220 ohm resistor will likely be fine.