How to operate a relay with Arduino?

I have a light switch (pictured on left) which has two wires blue and yellow. It is a spring mechanism type that comes up when tapped.
Tap it once light are on. A second tap and lights turn off.

I measure about 29V when the button is not pushed down. When I tap it the voltage drops momentarily down to 0V. The lights then turn on if they were off previously. If the light were already on they turn off.

All wires go to a "utility room" where there is a relay in a relay enclosure just like pictured on the right. It makes a clicking sound when light switch is tapped.

I'd like to have an Arduino control lights. I am not sure what is the best way and how. Should I connect Arduino to the light switch or to the utility room? And how do I manage the 30V issue?
I would also like to record when lights are on and off.

After posting 37 times, don't you think some important information would be if the voltage you measured was AC or DC?



Hmmm… that relay is marked 24V~ 6V= which I THINK means “24 Volts AC OR 6V DC”

BUT the safest/easiest thing is to use the Arduino with a relay that connects in parallel with the switch. That way you don’t need to worry about voltage levels, the existing equipment etc.

Your code should “remember” what it last did for ON and OFF. If you will leave it unattended for a long time it MIGHT get out of synchronization. You might add a simple photoresistor sensor in the room so the Arduino can KNOW if the light is on or not. Or burned out ?? :slight_smile:

See this overall Info page:

lots of questions.

3-wire switch. (2 blue?)
relay is that an impulse relay (think ball-point pen that clicks, once then retracts)

voltage ? were is that measured? across a coil, from terminal to ground ? what terminal ?

I am guessing you have an impulse relay, closes on one impulse, opens on the next, a toggle of a sort.

Also guessing that you do not care to have the Arduino know the state, just that whatever state it is in, you want the opposite when you trigger it.

Any simple relay can be used to mimic the switch. Power it on for a moment, then off.
The impulse will toggle your lighting relay.

No reason you cannot leave the existing switch in the circuit.
[ you can put in parallel. ]
if you really want to know the state of the relay, just measure the voltage across the contacts. (back to question #1)

Closed contact = 0 voltage drop, open contacts = high voltage, assuming there is any load connected.

as a note on the voltage, a 24VAC transformer will output something around 24 volts, much higher without any load, and lower with a high load.
[ you can locate a relay anywhere ]