Keeping Manual On/Off Alongside Remote Relay Function

I just started experimenting with using an Arduino and various remote system protocols (IR, Bluetooth, Low Freq RF, sound/light activation, etc) to control a relay to turn on/off a simple desk lamp. It's a plain jane desk lamp that originally had a filament bulb, I've stuck in an LED bulb.

I chopped the AC live wire and stuck it into the relay, things are working okay. Both relay and lamp switch have to be on for it to be on, or either of them off will have it off. Like they're just two switches in series, really. Perhaps the reverse would be preferable- both have to be off to have it off, but only one needs to be on for it to be on.

I'm wondering what the best ways are to keep the original on/off switch on the lamp still functional. So if the relay is off, the lamp can still be turned on/off with its switch. Or even true 3-way functionality where either one can turn the lamp on or off interchangeably if that's not too complicated.

Dear INTP,

The Job is doable, all what you need is to connect the switch to one GPIO that is not used by the relay, and the other end of the switch will be grounded.

within your code you check the change state of the GPIO to trigger your switch.

this way you can trigger you device manually as well as from your application

regards Samir Tafesh

Or you could put your on/off switch in parallel with the relay contacts

regards

Allan.

Dear allanhurst,

Adding a switch in parallel to the relay, will limit the control of the circuit, for example: when the relay is closed, the light will be always on even if we trigger manually the switch, and vice versa. while detecting switch change state and change the relay state will work in both cases.

Sorry to comment on your solution, but i believe that the circuit should understand that the switch has been triggered (or changed in status)

Allan's solution was answering the first proposed system, either on = on, both off = off.

I don't think a relay is the ticket for 3-way setup, it would be wasting energy if relay was on but switch turned light off. Needs a different kind of switch, like an electronic signal run toggle, so it only uses power to switch, not hold.

Dear INTP,

this is exactly what I meant, the switch will trigger the relay to ON or OFF, and it will never be on while the light is off

@Samir, let me see if i understand your solution... you put another relay in to an arduino port that is not used by the relay?

I am working in a project for home automation with xbee + ethernet and i am stuck there also, i was thinking about making another switch button that would replace the manual one and this button would countrol the relay, and also the master board would send command to control this relay too, i was afraid of doing that cause then i would to rely 100% in arduino board, i think i will do that and make 1 month test in my room..

Do you think this would work?

Just watched a vid on 3-way switches for home AC circuit. Two SPDT switches is all it takes and the additional wire between relay switch and manual switch is prob what Sam was getting at.

Need a latching relay that has NO and NC.
My current relay doesn’t have a NO terminal and isn’t latching, but I get what is needed.

Cna you share de video INTP?

https://www.youtube.com/watch?v=6_TpKdYeQaU

Great, clear, concise animation.

Dears,

the solution can be made in tow senarios,

1- two way switch, relies entirely on the ardruino, and the logic of switch on /switch off will be managed by the arduino code

2- three way switch, where the arduino relay will act as a normal three way switch as well, in this senario we do not rely on the arduino, the advantage in this senario is that the circuit will work even if the arduino is powered off, the disadvantages are that in some cases the relay will be activated while the light is off, another disadvantage is that your application cannot know the actual state of light (ON or OFF)

In both scenarios we do not need to add extra relay, to make things clear, i will prepare two presentations one for each scenario, and i will post them in the coming week

Regards
Samir Tafesh

Dears,

I have tested the two way switch today, and it is working great.

My setup is the following:

ESP8266-01 ( in replacement for the Arduino)
and home designed relay board connected to the ESP

the Relay is connected to GPIO 2
the two way switch is connected (1- GRND , and 2- to GPIO 3)

in the code i have three parameters:

int buttonState = HIGH; // variable for reading the switch change state
int relayState = HIGH; // variable for reading the Relay status
int switchState = HIGH; // variable for holding the current switch state

in the Setup()

void setup ( void ) {
pinMode(2, OUTPUT); //
digitalWrite(2, HIGH); //Switch relay off, before starting the setup module
relayState = HIGH; // equal to GPIO setting, used as global varialble to keep status available to every body

digitalWrite(3, HIGH); // Setting GPIO3 to HIGH in preparation to manual intervention

switchState = digitalRead(3); //GPIO 3

in the loop()

buttonState = digitalRead(3); //GPIO 3
if (buttonState != switchState) {
switchState = buttonState;
if (relayState == HIGH) {
digitalWrite(lightPin, LOW);
} else {
digitalWrite(lightPin, HIGH);

}
delay(1000);
}

your arduino code will fit in here

}

Hope it clarify the scenario with 2-way switch

Regards
Samir Tafesh

SamirTafesh: 1- two way switch, relies entirely on the ardruino, and the logic of switch on /switch off will be managed by the arduino code

Do you think this would work for a house switch? I mean, can we really rely in arduino for such critical use like this? Thanks samir, i seen your project and it is a great project

@samir

i will try your code with my project in this case i need to work the ethernet page button + digital button switch plugged arduino thanks

Dear wkpedro,

Happy to see that you liked the solution, and if you need any help please ask so,

Regards Samir Tafesh

Ok, thanks Samir This i believe will be the most important part of my project e believe, but i am not there yet.arduino nanos as slaves also with xbees. i choose xbee because i am noob, and i read about and seemed to me really noob friendly, I am trying to make an xbee network with a arduino mega master with xbee plugged in, and I am trying to stabilish communication first with the arduino Master with the Slaves I already can send comands from the web page in the Master, read n execute commands in the arduino Slave, but the slave is sending the state back to the master and it is not reading. It is easy to send commands with xbee with a "serial.println" but you have to do some coding for the reading since you need to read a string and not only one character. and then things do not ends well for the Master, I dont know how i am gonna make him read strings coming from serial while doing the page interface, cause the page will be all controlled by the relays states around the house, and these states will be sended with a certain seconds rate to the master, which will do the interface, android app + web page to start

you can watch my thread in the forum if you and any ideas and would like to share would be welcome thanks samir

Dear wkpedro,

Thanks for the reply, but please provide the link to your thread so i can read and check.

regards Samir Tafesh

http://forum.arduino.cc/index.php?topic=416558.0 Thanks Samir THanksfor you reply

The is also a solution i founded which i found very good choice to keep manual and relay function You would use a optocoupler 4n25, to read an analog port of arduino, optocoupler will have another of its pin attached to the lamp circuit and this will give status for arduino.

|500x375

It is portuguese but if u google translate everything you will be able to understand most of the simple content here with a solution for a huge problem https://www.paulotrentin.com.br/eletronica/detectando-status-de-lampada-com-optoacoplador-4n25-e-arduino/ thanks