Wiring 4 or 8 channel relay to wall switches (on/off)

Hi,
I know how to use a 4/8 way relay switch with arduino to control lights/fans/etc which are directly connected to the mains using a 2 pin plug and also connected to the relays.

Now I would like to connect the relays to the wall switches directly in my bedroom which are connected through internal wiring to the fan/lights.

Attached image of the wiring sketch comprising arduino + bluetooth module + relay. Bluetooth connects to mobile app to toggle the relay.

I would like to know how to wire the on/off switch to the relays. Attached an image I found while googling but it doesn’t give any information on wiring relays to the wall switch. The wires in yellow are what I need help wiring.

Any help please?

Thanks

wire.jpg

At the risk of sounding like a keyboard jockey smart-ass, I would recommend you hire a qualified electrician. Why? Because the photograph you posted (wire.jpg) shows that you are well outside your comfort zone of experience. That exposed, bare copper wire at the relay terminal blocks is lethal.

All of those parts and wire must be contained within an enclosure that is safe from inserted fingers and other foreign objects. You're risking bodily harm and fire working with household mains.

Quite frankly, if someone needs to explain to you how to wire a switch in series with a switch, you absolutely don't have the skill necessary to complete such a task safely.

Hi,
The wiring photo is someone else's. I just googled it. Yes, I know that proper shielding/covering of components is essential to prevent any accidents.

When working with mains I'll definitely ask my local electrician to do the actual wiring.

Just would like to understand the process involved to increase my knowledge though.

electric power wiring 101
circuit protection. everything must be protected.
your breaker in the USA is rated at 15 amp for residential lighting.
the wire is 14 ga. rated at less than 20 amps, but more than 15 amps. the breaker will trip beofre the wire overloads. circuit is protected.

your project has the breaker and wire to the the switch, but your relays are not rated for 20 amps.

this means you ahve to eitehr add a new circuit breaker that is rated lower than the lowest device or wire, or get relays that are rated for more than you existing circuit protection

google SSR, you can find cheap chinese ones that are "LABELED" for 30 amps, but fail at 20 amps because they are bootleg and made incorrectly.

first things first, get the correct parts.

you do not want to fight your insurance company over a loss and they show that you have illegal devices wired.

getting the basics right is vital.

I highly recommend you use the older X10 or new Insteon kind of interface.

Burning your house down or electrocuting someone can be very expensive.

.

your statement is not sufficient. you can replace your switch with a relay, control that from your Arduino.

but, it sounds like you want to keep your switches AND add the function of the arduino.

if you know a good Venture Capitalist, PM me off-list.

what you can do is to add a new wall box for the new relays. then run the power to the relays and allow your new (correctly sized) relays to BYPASS the switch.

if you want to have the switch in the circuit, then the switch needs to be changed. the common switch position of up/down would not work unless you added a motor in the switch that allowed your controls to change that. and, all you are doing is moving the switch handle so you see it up and down. nothing to do with the power.

you can change to a button style, or center position, spring return.

but what would happen is that your switch now becomes an input to your controller that then controls the relay.

if the 3-way type of switch is acceptable, then up and down are not related to on and off, it could on with the switch down or up. much simpler and standard 3-way switches.

what is needed it to get your specifics laid our completely.
once you have a fixed goal, the rest is very straight forward.

LarryD:
Burning your house down or electrocuting someone can be very expensive.

Actually, that bit can be done pretty cheaply.
It is the aftermath that can get costly.

:wink:

I second what Larry said - [u]X-10[/u] or one of the other existing home automation systems/protocols is the way to go.

There are lots of engineering & construction challenges involved in making a remote controlled switch that that works without any additional house wiring, and that fits into a regular switch box. Installing a “proper” home automation dimmer/switch is as easy as replacing your regular switch,and it will continue to work normally/manually as well as remotely.

If you want to build a compatible controller/transmitter that works with Bluetooth or Wi-Fi, you can build that, or you can buy that too. (Most of these switches use a proprietary control protocol so you can’t directly control them with Bluetooth, but you should be able to get a Bluetooth bridge/router.)

…I’ve had a home automation system (with about 10 controlled lights/outlets) for many-many years. I didn’t build any of it myself and my setup has a master timer/controller and a few “manual” remote controllers. It can’t be controlled by Wi-Fi or Bluetooth but that could easily be added.

Thanks guys.
I am aware of X10/Insteon and home automation commercial products available in the market.

The entire point of this exercise is to experiment with Arduino and see whats possible and whats not when converted into real world applications. Of course, when working with mains, safety is critical and the main priority.

Remember, safety is one thing legality is another.

.

You don’t say what part of the world you are in. There are different codes and techniques for different areas. I can’t really comment if you are outside of north america, but the circuit would be the same. the terminology and voltages will be different.

In my simple drawing, I show a 2 pole stardard switch, and a light bulb. What you want to do is put your relay in parallel with the existing switch, so either the relay or the switch will turn on the light.

Connecting the circuit may not be as straight forward as you want since the wiring will be inside the walls and not all run to a central point or “home run”.

In the drawing, the grey wire from the mains is what is called (in the USA) the NEUTRAL wire. If you measure the voltage between a ground or earth point to this wire with no load on the circuit it will show zero or a very low voltage.

The red wire from the mains is called the “hot” wire. This is the dangerous one. If it connects through you to the neutral or ground you get a shock. This wire is switched because when the switch is open, the light socket and wire back to the switch is all dead. So this makes it safe to change light bulbs with the switch off. If the circuit is wired incorrectly then the bulb will be “hot” all the time but still will only light when the switch is closed.

Your relay contacts (the blue wires) will mimic the action of the wall switch to turn on the light.

The problem with doing this in an existing building is the way the building is actually wired. Normally the wires from the mains are run to the light fixture. From there an identical pair is run down to the switch. At the light fixture the hot wire from the mains will be only connected to one of the wires going to the switch and the neutral will go directly to the light socket terminal of the threaded part. The wire connected to the hot goes to one terminal of the switch. The other wire in the pair is connected to the other switch terminal and then to the center terminal of the light socket center terminal.

This example is only for a one switch, one light circuit. There are many variations.

Here in the USA it is legal for a HOMEOWNER to do their own wiring, but it must be under a permit and signed off by an inspector to be legal. This includes any modification of existing circuits, breakers, etc. Legally, since the 2015 code the only thing you can do without a permit is replace an existing light bulb with an identical replacement. It is very restrictive.

When installing any electrical equipment, it must be rated for the voltages, loads, and location.

Mains voltages need to be respected not feared. ALWAYS turn off and lock out the voltage source. If you work on mains equipment always have a volt meter and one other kind of tester like a non contact pen type tester to verify that everything is dead…so you won’t be. The higher voltage the more important this is.

Hi Jeff,
Thanks for the inputs. I am in India and we work on 240V power supply.

ok, thats fine, the function of the wires will be the same.

So you will have one wire, we call the neutral that will be zero volts between it and earth, and one wire we call the hot wire, that will be 240v to earth.

In your country, the neutral wire is BLACK or BLUE, the hot wire is BROWN or RED and earth is GREEN or GREEN/YELLOW.

Just be aware that there is more than one type of wiring service.

Residential or small shop will be what is called SINGLE PHASE as above and larger building and industrial will be THREE PHASE which has THREE hot wires, RED, YELLOW, BLUE and one neutral BLACK with the same GREEN for earth. Also know that on a three phase system the voltage between any two hot wires will be 415 volts. Just stay away from that, it is very dangerous, and your little inexpensive volt meter will probably just explode if you try to use it at 415.

Be safe!

Light switching is pretty straight forward and works with opening one wire.
You can switch hots, or switch neutrals. Break one leg and the lights go out.
It is not uncommon to power the switch, and then run wire from the switch to the light.
it is not uncommon to run power to the light and then run the hot to the switch and then the second wire becomes a hot when the switch is closed, and therefore connect to the light. this is switching the hot leg and has the problem that the light has two neutral wires connected.
in a 3-way application the wiring becomes more elaborate and in the US, we prefer to use 3 separate colors, red, black and white. in the US. white is the neutral, so the red and black carry the hot side of the circuit.

If you want to add a relay to your circuit, you can put it either at the switch box, or at the lamp box.

We can get extra deep switch boxes to accommodate extra wiring or a relay
we can add a second box to make it double wide, with the relay in the second box and show indicators on the cover or have a blank cover.
if you are adding to a light in the ceiling and you have access to the area above the ceiling, you can add a junction box and put your relays in that.

Guys..how safe is this?

It is only as safe as the circuit protective devices which consist of fusing and circuit breakers in the correct places with the correct ratings. That project looks reasonable by US electrical codes for 120 volt mains. The solid state relay board contains inline pico fuses to protect the PC board, that is a good thing. I cannot tell if the relay board has the proper trace widths and spacing but since it has fuses, it's better than the Chinese boards without.

I cannot state suitability for 240 vac mains, your codes are quite different due to the different distribution methods.

The comment section had some typical Internet nonsense. The electrician comment that the box was wired incorrectly and it would cause inductive heating. That's pretty funny stuff. Yeah, that's why we switched to plastic boxes /sarc.

As a hobby project, it may be worth considering some RCD/ELCB device in the supply.
They're a little unusual in lighting circuits because people are typically well isolated from the lighting wiring.
In this case it may be worth installing (by a licensed sparky) - even if only during development- to save any innocents from accidentally discovering a wiring or installation issue.

The only problem is that the variability in skill of people attempting this. You can't assume it will be followed to the letter.

dave-in-nj:
Light switching is pretty straight forward and works with opening one wire.
You can switch hots, or switch neutrals. Break one leg and the lights go out.
It is not uncommon to power the switch, and then run wire from the switch to the light.
it is not uncommon to run power to the light and then run the hot to the switch and then the second wire becomes a hot when the switch is closed, and therefore connect to the light. this is switching the hot leg and has the problem that the light has two neutral wires connected.
in a 3-way application the wiring becomes more elaborate and in the US, we prefer to use 3 separate colors, red, black and white. in the US. white is the neutral, so the red and black carry the hot side of the circuit.

Do not switch neutrals. All kinds of Wrong.

OMR