Arduino get data from Wall light switch

Hello,

Do you know any tips that can help me with how to send data to an arduino pin from a wall light switch?
What I'm trying to do is :
Open my light from my wall switch
Get a notification from arduino that my lights are open

I have basic knowledge about the subject.
I have used a relay to open and close my lights from arduino but when I'm using arduino and normal switch one of them gets confused and it is displayed as on when it's off.

What I'm thinking is to use the light switch only for sending data to arduino and then arduino control the relay, also the data will update if the lights are on or off and the command from the serial port will be controlling the relay.
Thanks for your time I'd love to hear all the suggestions

I'd love to hear all the suggestions

I suggest you ask a moderator to move this topic to a more appropriate section.

Hello,

Do you know any tips that can help me with how to send data to an arduino pin from a wall light switch?
What I'm trying to do is :
Open my light from my wall switch
Get a notification from arduino that my lights are open

I have basic knowledge about the subject.
I have used a relay to open and close my lights from arduino but when I'm using arduino and normal switch one of them gets confused and it is displayed as on when it's off.

What I'm thinking is to use the light switch only for sending data to arduino and then arduino control the relay, also the data will update if the lights are on or off and the command from the serial port will be controlling the relay.
Thanks for your time I'd love to hear all the suggestions

He posted the same thing... twice.

Anyways.. since you mentioned that you no longer want to use the wall switch/switch plate to control the lights... but only 'notify' the Arduino..

then just dis-connect the wall switch from your 'lights'.. and connect it to a I/O pin on the Arduino directly.. (using the correct gauge wire and of course GND or V+ and your I/O pin of choice)

This way it is NO different then toggling the lights using the Arduino via a button press.

xl97:
He posted the same thing... twice.

Anyways.. since you mentioned that you no longer want to use the wall switch/switch plate to control the lights... but only 'notify' the Arduino..

then just dis-connect the wall switch from your 'lights'.. and connect it to a I/O pin on the Arduino directly.. (using the correct gauge wire and of course GND or V+ and your I/O pin of choice)

This way it is NO different then toggling the lights using the Arduino via a button press.

I'm new to this forum I'm sorry....... Thank you I'll try it.

Rather than kill yourself while illegally modifying household wiring, it would be easier and completely safe to use an LDR (light dependent resistor) to sense whether the lights are on.

jremington:
Rather than kill yourself while illegally modifying household wiring, it would be easier and completely safe to use an LDR (light dependent resistor) to sense whether the lights are on.

Hmm is it illegal to change the wall switches? Also I have basic knowledge of what I'm doing I am not that much of a noobie.

I don't really understand your question but the "classic problem" is that the wall-switch is on (up) but the relay has turned the light off (or vice-versa).

A standard [u]home automation switch/dimmer[/u] solves the problem with momentary switches. Push the top part of the switch and you get a "on" or "dim-up" command. It can get a local command or a remote command and it simply remembers (or holds) the last command.

Another solution is to get a "3-way" (double-throw) switch and a double-throw relay and wire it like a [u]wire it like a 3-way switch[/u]. With this setup sometimes up is on and sometimes up is off, but whenever you flip the switch (or change the relay state) the on/off state of the light changes.

With the "3-way" solution you need another relay to tell the software if the light is on or off.

Hmm is it illegal to change the wall switches?

Not here in the U.S. I've done LOTS of re-wiring and I'm not a licensed electrician. But, if you change the wiring you are likely to be violating your local electrical codes (simply because you don't know all the codes) and that could be a problem if you sell the house, or if it burns down the insurance company might give you trouble, or if somebody gets electrocuted.

I've done LOTS of re-wiring and I'm not a licensed electrician.

Unless you got a permit and had an inspection done, that activity put you legal jeopardy (by all local building codes that I know of).

National Electrical Code (Wikipedia entry):

In the U.S., anyone, including the city issuing building permits, may face a civil liability lawsuit for negligently creating a situation that results in loss of life or property. Those who fail to adhere to well known best practices for safety have been held negligent. This liability and the desire to protect residents has motivated cities to adopt and enforce building codes that specify standards and practices for electrical systems (as well as other departments such as water and fuel-gas systems). This creates a system whereby a city can best avoid lawsuits by adopting a single, standard set of building code laws. This has led to the NEC becoming the de facto standard set of electrical requirements.[6] A licensed electrician will have spent years of apprenticeship studying and practicing the NEC requirements prior to obtaining his or her license.

jremington:
Unless you got a permit and had an inspection done, that activity was in fact illegal (by all local building codes that I know of).

I understand what you all say and I know that it is dangerous for me to change those type of things but Iam pretty sure that I know how to turn off the main relay of the house for a couple of minutes. This is not my first project and I have played with high current lots of times. Also I am not from U.S. I'm from Greece and I'm not planning to sell the house or get electrocuted.

But there are SO MANY EASIER ways to tell if the lights are on!

And, if the bulbs are burned out, the switch setting is meaningless.

jremington:
But there are SO MANY EASIER ways to tell if the lights are on!

And, if the bulbs are burned out, the switch setting is meaningless.

The suggestion you did earlier about the LDR sensor will this get triggered by the natural light from the window?

Threads merged.

The suggestion you did earlier about the LDR sensor will this get triggered by the natural light from the window?

Not if you put the LDR close to the bulb, or enclose it in a tube pointing at the lamp, and adjust the sensitivity correctly.

jremington:
Not if you put the LDR close to the bulb, or enclose it in a tube pointing at the lamp, and adjust the sensitivity correctly.

Ok I see but in my case the bulb is in the ceiling and the hub that I have all the arduino stuff is next to the window also it is not that good to go on and add a tube in the room. I'm trying to do it as stealthily as possible.

Since you have a relay operation the light already and obviously have wires run to the light, why not monitor the voltage on the output of the relay.

If the light is turned on via the wall switch there will be voltage on the output of the relay event if the relay is not on, indicating that the lightswitch is on.

If the relay is turned on then there will also be voltage at the relay.

There will be no voltage only when the light is turned off.

A small "whatever voltage" plugpack that outputs 5 volts dc will then let you connect to the Arduino.

Better yet replace the light with a low voltage LED light and run the whole lot off a low voltage transformer where it will,only tingle when you grab those bare wires instead of fill the room with the sound of Sizzling Bacon!

Please Note: No matter how skilled you are it is very easy to get shocked. I speak from experience in a moment of forgetfulness and panic untill i realised the fuse had blown, not my eyes.

Daz

Daz1712:
Since you have a relay operation the light already and obviously have wires run to the light, why not monitor the voltage on the output of the relay.

If the light is turned on via the wall switch there will be voltage on the output of the relay event if the relay is not on, indicating that the lightswitch is on.

If the relay is turned on then there will also be voltage at the relay.

There will be no voltage only when the light is turned off.

A small "whatever voltage" plugpack that outputs 5 volts dc will then let you connect to the Arduino.

Better yet replace the light with a low voltage LED light and run the whole lot off a low voltage transformer where it will,only tingle when you grab those bare wires instead of fill the room with the sound of Sizzling Bacon!

Please Note: No matter how skilled you are it is very easy to get shocked. I speak from experience in a moment of forgetfulness and panic untill i realised the fuse had blown, not my eyes.

Daz

The arduino is the test bench for me. In the future when I will find all the code and the how to plug things correctly I am going to transfer this to a esp8266 controlled by blynk so the power for the arduino is not a problem here.

About your suggestion though I am not sure that I understand it fully. How can I monitor the output voltage of a relay? Also if I do that and I close the lights from the wall and then try and open it from the arduino nothing will happen.

Smackflad:
Hello,

Do you know any tips that can help me with how to send data to an arduino pin from a wall light switch?
What I'm trying to do is :
Open my light from my wall switch
Get a notification from arduino that my lights are open

I have basic knowledge about the subject.
I have used a relay to open and close my lights from arduino but when I'm using arduino and normal switch one of them gets confused and it is displayed as on when it's off.

What I'm thinking is to use the light switch only for sending data to arduino and then arduino control the relay, also the data will update if the lights are on or off and the command from the serial port will be controlling the relay.
Thanks for your time I'd love to hear all the suggestions

I am having a lot of trouble with this.

OPEN MY LIGHT FROM MY WALL SWITCH.
I assume this means turn the light on and off like a normal room light.

GET A NOTIFICATION FROM MY ARDUINO THAT MY LIGHTS ARE OPEN.
You want the arduino to know the light has been turned on.

I HAVE USED A RELAY TO OPEN AND CLOSE MY LIGHTS FROM ARDUINO.
You have used an Arduino to turn the light on and off with a relay. (Note it is 'on and off' not 'open and close').

I do not understand this as you have not posted a drawing/circuit of what you have.
" but when I'm using arduino and normal switch one of them gets confused and it is displayed as on when it's off. "

The next bit you seem to be saying that you wish to run the switch direct to the arduino and use it to control the relay to turn the light on and off.

I do not understand this bit.

" the command from the serial port will be controlling the relay. "

Serial ports usually do not control relays.

Here is my guess!

You wish to monitor if the light is on or off and how long it is on for.
You want to use the Arduino to turn the light on and off.
You will eventually remove the Arduino and replace it with an esp8266 board that is a wifi board and there will be no Arduino.

Help me here, think carefully and post again.

Daz

I tried to put in the one end of the switch the arduino pin 9 and the other end the ground.
When the switch is on i receive in the serial monitor 0 but when it's off I receive random ones and zeros. I haven't added any type of resistor if I add one toy think that it will fix the problem? if yes what type of resistor will do the job?

Daz1712:
I am having a lot of trouble with this.

OPEN MY LIGHT FROM MY WALL SWITCH.
I assume this means turn the light on and off like a normal room light.

GET A NOTIFICATION FROM MY ARDUINO THAT MY LIGHTS ARE OPEN.
You want the arduino to know the light has been turned on.

I HAVE USED A RELAY TO OPEN AND CLOSE MY LIGHTS FROM ARDUINO.
You have used an Arduino to turn the light on and off with a relay. (Note it is 'on and off' not 'open and close').

I do not understand this as you have not posted a drawing/circuit of what you have.
" but when I'm using arduino and normal switch one of them gets confused and it is displayed as on when it's off. "

The next bit you seem to be saying that you wish to run the switch direct to the arduino and use it to control the relay to turn the light on and off.

I do not understand this bit.

" the command from the serial port will be controlling the relay. "

Serial ports usually do not control relays.

Here is my guess!

You wish to monitor if the light is on or off and how long it is on for.
You want to use the Arduino to turn the light on and off.
You will eventually remove the Arduino and replace it with an esp8266 board that is a wifi board and there will be no Arduino.

Help me here, think carefully and post again.

Daz

What I'm trying to do :
Turn on and off the lights from Wall switch (like normal rooms)
Turn on and off the lights from arduino relay

Side things :
If I turn on the lights from the wall switch I need arduino to know that I've done it.

Temporary things :
I use arduino uno.
Serial monitor + coding turn on a relay.
I have a temporary wall switch that I use to try and find the solution.

I hope that made things a little bit easier for you.
Thanks for your time.