dlink377
Posts: 21
Joined: Thu Mar 21, 2013 3:34 pm

[?] Light Switch

Fri May 02, 2014 10:52 am

Hi,

After successfully controlling my TV, STB, and AC system with IR blaster, I want to improve my home automation Pi to control the light switches.

From what I learn I can just bought cheap 5V relay board from eBay and connect the wire directly. But this solution doesn't give any override / manual function in case of error in RPi. I also learn that I can use remote controlled bulbs, but that is quite costly and I cannot use standard switch.

I want a system that can be controlled with Pi and simple light switch. Pi can turn on and turn off the switch, so do the switch. I also take a look two terminal switches, but how the Pi know the light is turned on or off, and there is no two terminal relay available for cheap.

Any suggestion?

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: [?] Light Switch

Fri May 02, 2014 11:10 am

Caution! cheap relay board may not work with mains voltage!
Do not burn down your house!

I accept no liability should you be injured or your property damaged from following this advice!


you need a relay with common, normally open and normally closed positions, replace one of the switches in the diagram (below) with the relay. Connect the common position of the relay where the common position of the switch is, run two wires to the other light switch (one to each of the switch contacts, one coming from the normally open relay position, one from the normally closed relay position).
Image

you may need to give your Pi some way of monitoring the other switch, or the light output as it won't otherwise know which position the other switch is in.

edit:
Suggestions for monitoring light:
add a mains voltage relay in parallel with the light? Pi monitors relay output, relay comes on when light is on.

Caution! cheap relay board may not work with mains voltage!
Do not burn down your house!

I accept no liability should you be injured or your property damaged from following this advice!
Doug.
Building Management Systems Engineer.

dlink377
Posts: 21
Joined: Thu Mar 21, 2013 3:34 pm

Re: [?] Light Switch

Fri May 02, 2014 11:36 am

BMS Doug wrote:
you need a relay with common, normally open and normally closed positions, replace one of the switches in the diagram (below) with the relay. Connect the common position of the relay where the common position of the switch is, run two wires to the other light switch (one to each of the switch contacts, one coming from the normally open relay position, one from the normally closed relay position).
Image
you may need to give your Pi some way of monitoring the other switch, or the light output as it won't otherwise know which position the other switch is in.


Well, I don't quite understand about it. My electrical skill is so decent (I am a web programmer), I even had minor burn on my hand when soldering the IR blaster circuit that I don't understand at all.

This is a two way light switch
Image

This is a standard relay
Image

Do you mean to connect Common in switch to Common in relay, L1 to Open, and L2 to close? Where do I connect the hot wire from wiring and hot wire to the light?

Where can I find high quality of relay board? I prefer finished product such as the picture above though. If DIY with buying the part if cheaper and provide higher quality I will do it.

I don't understand how to control the relay with the Pi. Usually it is only active GPIO pin so it will send 3.3v, is it the same?

For the monitoring, probably another circuit to detect 230V? Just connect the cable from the light wiring to the circuit so Pi know the light is powered or not. The problem is, I need to pull a new wire (ground) from the light again because the ground wire is directly connected to the light, not passing the switch box.

Thank you for your reply.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: [?] Light Switch

Fri May 02, 2014 12:47 pm

Use a solid state relay for controlling mains (120-240) voltages.

Get the correct one and no special interfacing is required. Just hook up to a GPIO pin and go.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: [?] Light Switch

Fri May 02, 2014 12:59 pm

EDIT: My statement below is incorrect. See further down thread for explanation.

I rather like the red warnings in the first reply, especially in the light (no pun intended) that removing mains light switches and sockets is now strictly forbidden in the UK unless you're a qualified electrician holding the relevant certificates. Not preaching, just pointing it out incase the OP lives in the UK and wasn't already aware. ;)
Last edited by GTR2Fan on Fri May 02, 2014 3:48 pm, edited 1 time in total.
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

hampi
Posts: 223
Joined: Fri May 31, 2013 11:29 am
Contact: Website

Re: [?] Light Switch

Fri May 02, 2014 1:25 pm

dlink377 wrote:Any suggestion?
For the LED lights with 12 V DC power supply I have a DIY solution

https://github.com/oh7bf/RasPiPwrSwitch/wiki

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: [?] Light Switch

Fri May 02, 2014 2:38 pm

dlink377 wrote:
Image

Well, I don't quite understand about it. My electrical skill is so decent (I am a web programmer), I even had minor burn on my hand when soldering the IR blaster circuit that I don't understand at all.

This is a two way light switch
Image

This is a standard relay
Image

Do you mean to connect Common in switch to Common in relay, L1 to Open, and L2 to close? Where do I connect the hot wire from wiring and hot wire to the light?

Where can I find high quality of relay board? I prefer finished product such as the picture above though. If DIY with buying the part if cheaper and provide higher quality I will do it.

I don't understand how to control the relay with the Pi. Usually it is only active GPIO pin so it will send 3.3v, is it the same?

For the monitoring, probably another circuit to detect 230V? Just connect the cable from the light wiring to the circuit so Pi know the light is powered or not. The problem is, I need to pull a new wire (ground) from the light again because the ground wire is directly connected to the light, not passing the switch box.

Thank you for your reply.
In the above drawing the Hot wire is marked as Live, connect that to your existing switch Common (marked C in your picture).
connect your L1 to the Normally open position of your relay.
connect your L2 to the normal closed position of your relay.
connect your relay's common position to the lamp (this is your switched live).
Your relay board must be rated to withstand your mains voltage (and you need to be sure that this isn't just a fictional rating, mains voltage isn't a friend of your Pi, or your house if the relay blows up)
GTR2Fan wrote:I rather like the red warnings in the first reply, especially in the light (no pun intended) that removing mains light switches and sockets is now strictly forbidden in the UK unless you're a qualified electrician holding the relevant certificates. Not preaching, just pointing it out incase the OP lives in the UK and wasn't already aware. ;)
That's not completely true, in the UK it is permissible to replace light switches and power sockets without any certification.
Anyone can install a new circuit but it is required that the work is certified afterwards by a Part P inspector.
Doug.
Building Management Systems Engineer.

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: [?] Light Switch

Fri May 02, 2014 3:21 pm

BMS Doug wrote:That's not completely true, in the UK it is permissible to replace light switches and power sockets without any certification.
Anyone can install a new circuit but it is required that the work is certified afterwards by a Part P inspector.
Thanks. I'll look into that rather than continuing the Chinese whisper that seems to have befallen upon my ears. :P

EDIT: That's put my mind at rest! Regulation 12(6A) of Part P seems to cover us from the perspective of ruling in what does need certification, and that anything not covered by that rule classifies as 'Non-notifiable work'. Thanks for the heads-up. :)
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: [?] Light Switch

Fri May 02, 2014 4:04 pm

GTR2Fan wrote:
BMS Doug wrote:That's not completely true, in the UK it is permissible to replace light switches and power sockets without any certification.
Anyone can install a new circuit but it is required that the work is certified afterwards by a Part P inspector.
Thanks. I'll look into that rather than continuing the Chinese whisper that seems to have befallen upon my ears. :P

EDIT: That's put my mind at rest! Regulation 12(6A) of Part P seems to cover us from the perspective of ruling in what does need certification, and that anything not covered by that rule classifies as 'Non-notifiable work'. Thanks for the heads-up. :)
you are welcome.

this doesn't mean that people who don't know what they are doing should replace their own sockets, just that you don't need a certificate to do so.

There are plenty of good installation electricians who don't have the part P certification, it's just that to comply with the law any "notifiable work" will have to be inspected afterwards.
Doug.
Building Management Systems Engineer.

dlink377
Posts: 21
Joined: Thu Mar 21, 2013 3:34 pm

Re: [?] Light Switch

Fri May 02, 2014 5:14 pm

Richard-TX wrote:Use a solid state relay for controlling mains (120-240) voltages.
Get the correct one and no special interfacing is required. Just hook up to a GPIO pin and go.
The Solid State Relay doesn't have any NC or NO state connector? How do I connect to the second switch for failover?
hampi wrote:For the LED lights with 12 V DC power supply I have a DIY solution
https://github.com/oh7bf/RasPiPwrSwitch/wiki
Unfortunately I want to use AC, rather than DC. But maybe will use it as background lighting for my TV LED strip. Thanks!
BMS Doug wrote: In the above drawing the Hot wire is marked as Live, connect that to your existing switch Common (marked C in your picture).
connect your L1 to the Normally open position of your relay.
connect your L2 to the normal closed position of your relay.
connect your relay's common position to the lamp (this is your switched live).
Your relay board must be rated to withstand your mains voltage (and you need to be sure that this isn't just a fictional rating, mains voltage isn't a friend of your Pi, or your house if the relay blows up)
I understand it now and how it works. One question, how can I find the most durable and safe relay to use? Do you have any suggestion in that? Or can I use SSR as Richard-TX suggested it that I find it better because there is not click noise.I don't want to burn my house down just because of the cheap things.

I cannot find the 240V relay in the internet to tell the Pi if the light is turned on or off. What is the name so that I can find it easier?

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: [?] Light Switch

Fri May 02, 2014 7:38 pm

dlink377 wrote: I understand it now and how it works. One question, how can I find the most durable and safe relay to use? Do you have any suggestion in that? Or can I use SSR as Richard-TX suggested it that I find it better because there is not click noise.I don't want to burn my house down just because of the cheap things.

I cannot find the 240V relay in the internet to tell the Pi if the light is turned on or off. What is the name so that I can find it easier?
Glad to help.

For the relay I would look for an industrial design, but that's me (I don't normal deal with domestic scale electrical wiring).

The monitoring relay should be a single pole (one contact) single throw (common to normally open or common to normally closed, either one would suit your purpose, no need to pay extra for dual throw (common, normally open and normally closed contacts).
Acronym-ise the above. SPST relay
Add your mains voltage to the search term.

For the relay that switches the mains you would need a single pole dual throw (SPDT) relay, possibly a 5v coil (switched by a transistor?).
If you mounted the pi switching device in the ceiling near the lamp you could build both relays and the pi into one enclosure (requires a false ceiling)
I don't have any experience with solid state switching, by my understanding it's good for the normally open switching but not so good when you want to do normally closed. (Or was it the other way around?).
Doug.
Building Management Systems Engineer.

Tarcas
Posts: 740
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: [?] Light Switch

Fri May 02, 2014 10:04 pm

I don't have any experience with solid state switching, by my understanding it's good for the normally open switching but not so good when you want to do normally closed. (Or was it the other way around?).
What I know about solid state relays is that:
They're more expensive.
They last longer (~1,000,000 cycles as opposed to 100,000 with standard ones.)
They don't make the click that standard ones do.
You don't need the flywheel diode with them since it's not an inductive load.
They tend to fail in an "on" mode. If it fails, it really doesn't matter since you're doing three-way switching. This may be why you understand that they're better for one method of switching than the other. Sorry, I don't know more details about this, or if they fail quicker when left in one mode over the other. With three-way switching, you're likely to use each state approximately evenly, on average, unless you deliberately pay attention to which position you leave your manual switch in so that the relay can remain in the corresponding position.

dlink377
Posts: 21
Joined: Thu Mar 21, 2013 3:34 pm

Re: [?] Light Switch

Sat May 03, 2014 6:56 am

BMS Doug wrote: Glad to help.

For the relay I would look for an industrial design, but that's me (I don't normal deal with domestic scale electrical wiring).

The monitoring relay should be a single pole (one contact) single throw (common to normally open or common to normally closed, either one would suit your purpose, no need to pay extra for dual throw (common, normally open and normally closed contacts).
Acronym-ise the above. SPST relay
Add your mains voltage to the search term.

For the relay that switches the mains you would need a single pole dual throw (SPDT) relay, possibly a 5v coil (switched by a transistor?).
If you mounted the pi switching device in the ceiling near the lamp you could build both relays and the pi into one enclosure (requires a false ceiling)
I don't have any experience with solid state switching, by my understanding it's good for the normally open switching but not so good when you want to do normally closed. (Or was it the other way around?).
I will just extend the cable from the switch to a enclosure and replace the switch with two way switch.
The cable I need to run is: Main live wire, 2 L1 cables, 2 L2 Cables, 2 LiveWires for 2 light, and 1 common AC ground cable. Is that right? Total 8 cables. Any chance to decrease the cable count? since I may need to pull the wire
Will add some 1A or 2A additional MCB to Main Live Wire for extra protection in the enclosure. One light is only around 25W.

Based on my understanding, I need a relay that have NC and NO. I cannot find NC SSR relay on Internet, I only find this kind of NO 8ch relay on eBay and SainSmart:
Image
I think it is high quality because it is using OMRON SSR (CMIIW, don't have any experience in this).

So, I cannot use SSR for this project because I need failover switch (No NC on SSR), I will look for some traditional Relay that have NC and NO. I found some OMRON relays on eBay:

http://www.ebay.com/itm/8-SPDT-Power-Re ... 0343390234
But I need additional 24V adaptor, but I can directly connect to Pi 3.3V GPIO to control it (without additional resistor/soldering)

Is the quality is good enough for at least 2 year before change it with another unit? It is quite expensive (US$ 35 and I don't need 8ch, 4ch is good enough, since one Pi is for one Room), even the SSR is cheaper by half. I also need to buy 24V adaptor (probably will find DELTA unit for Notebooks) that will cost another US$ 10 to 20 more.

For the Monitoring relay, I still cannot find it. I try only return some random things that I don't even know what it is. I understand I must find a relay that receive control input of 240V, rather than 5V. And connect the contact to the Rpi that will act like a push button or switch so the Pi will know it. But, the problem is, I cannot find this kind of relay. Can you help me point out which is the right 240V relay? I don't want to spend so much money on this, because the main relay itself already cost an arm and leg.

No wonder home automation solution is very expensive, I don't know relay is very very expensive. I hope by using Pi i can create DIY high quality home automation though. Hahaha.
Tarcas wrote: What I know about solid state relays is that:
They're more expensive.
They last longer (~1,000,000 cycles as opposed to 100,000 with standard ones.)
They don't make the click that standard ones do.
You don't need the flywheel diode with them since it's not an inductive load.
They tend to fail in an "on" mode. If it fails, it really doesn't matter since you're doing three-way switching. This may be why you understand that they're better for one method of switching than the other. Sorry, I don't know more details about this, or if they fail quicker when left in one mode over the other. With three-way switching, you're likely to use each state approximately evenly, on average, unless you deliberately pay attention to which position you leave your manual switch in so that the relay can remain in the corresponding position.
It is cheaper if I compare the SainSmart SSR to the traditional Relay above though, I don't know about quality.

For cycles, I may add to the database to limit the usage to 80k cycles, to let me know when to change the relay set.

I love the click sound, but consider traditional switch also makes click sound, it doesn't really matter now.

I am doing two way switching, for failover if the relay board is failing or the control unit (such as iPad) is not available. If I don't need failover, I will just buy a SSR relay from SainSmart.

If this project is successful in one room (both in quality and economic scope), I will extend it to all bed room. I will use some chinese cheap tablet as the control unit in every room beside the existing manual switch to control the lighting, AC, TV, and STB.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: [?] Light Switch

Sat May 03, 2014 9:35 am

Because you are having an enclosure we can use din rail and and mount the relays, pi power supply and pi onto that.

Alternatively we could design a bespoke circuit board for the application and solder the relays to it. (This would be fairly simple to design and could be printed quite cheaply).

which country do you live in and what voltage is your mains power supply?
Doug.
Building Management Systems Engineer.

johndough
Posts: 254
Joined: Sun Jan 13, 2013 2:00 pm

Re: [?] Light Switch

Sat May 03, 2014 10:20 am

Hi

Somewhere earlier I posted something like this...

SOME SIMPLE RELAY KNOWLEDGE

Having worked with mains voltages, and lower, for about 45 years I want to attempt an explanation of how to control equipment etc with relays, digitally or manually switched.

These are my thoughts and views, and not a set of instructions on how to use any of the items or circuits mentioned. Mains voltage can and will KILL if allowed to.

My main relays of choice are Finder (http://www.findernet.com)and Telemacanique (http://www.schneider-electric.co.uk) both widely available from RS & Farnell just like a Pi.

The convention for naming relays and their terminals or contacts and connections will be:-

KR for a Relay and KM for a Motor rated relay. Coil connections are A1 & A2, for AC/DC.

In the case of multiple contact relays

Com Common 11 21 31 41
N/C Normally Closed 12 22 32 42
NB: Relays without C/O use N/O (13) (23) (33) (43)
N/O Normal Open 14 24 34 44
C/O ChangeOver

Pin Outs.PNG
Pin Outs.PNG (51.18 KiB) Viewed 8717 times




Above is a 2 pole & 4 pole Change/Over relay connection layout. Using 8 & 14 pins, (3 pole C/O would use 11 pins). Next terminal numbers for an 8 relay board. Lastly a 2 N/O & 2 N/C block


Now to veer off slightly and show a relay setup in conjunction with house lighting.
LightingMulti.PNG
LightingMulti.PNG (58.94 KiB) Viewed 8717 times


The 3 electric lamps, L1, L2 & L3 shown above are controlled in various ways.

L1: Simply adding a relay contactKR1 (Normally/Open) driven by your Pi will remotely switch the light ON/OFF so long as the local switch is OFF.

L2: Allows ON/OFF locally &remotely (2 way switching) using a Change/Over contact of KR2.

L3: This more complicated circuit has a pair of 2 way switches, with an INTERMEDIATE switch added (you can add more intermediate switches) and a relay KR3 with 2 Change/Over contacts used to replicate an intermediate switch. Giving 4 switching points


Therefore adding a Double pole Change/Over relay in a box, controlled remotely by a Pi can switch Domestic house wiring. However it has huge potential risk if you are inexperienced and could damage you and/or your property.

DO NOT carry out any work that is in contravention of your local laws and/or regulations.

These are my thoughts and views, and not instructions, accessing cabling within a property could lead to injury or death for you, and damage to property.

Tarcas
Posts: 740
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: [?] Light Switch

Sat May 03, 2014 3:49 pm

I will just extend the cable from the switch to a enclosure and replace the switch with two way switch.
The cable I need to run is: Main live wire, 2 L1 cables, 2 L2 Cables, 2 LiveWires for 2 light, and 1 common AC ground cable. Is that right? Total 8 cables. Any chance to decrease the cable count? since I may need to pull the wire
Assuming that you're modifying a light and switch that already are wired, the main modification that you need are the two (L1 and L2) wires between the relay and switch. You can minimize their length by mounting the relay close to the switch, and reuse the wires that are already running to the power source and the light.

If this is a new light and switch, wire count doesn't matter. Running a 4-wire cable is no harder than running a single wire in most cases. Just buy cable that makes sense for your installation. Plus for a new install, you should probably be getting permits and would need a licensed electrician for that anyway.

dlink377
Posts: 21
Joined: Thu Mar 21, 2013 3:34 pm

Re: [?] Light Switch

Sun May 04, 2014 6:54 am

BMS Doug wrote:Because you are having an enclosure we can use din rail and and mount the relays, pi power supply and pi onto that.

Alternatively we could design a bespoke circuit board for the application and solder the relays to it. (This would be fairly simple to design and could be printed quite cheaply).

which country do you live in and what voltage is your mains power supply?
Well, my soldering skill is the worst you can imagine. You can search in Google for "worst solder" and you can see how my soldering when doing the IR blaster board. If I will do the circuit by myself, maybe I will just order it online, or pay for more experienced people to do it. I cannot risk to solder a board that will drive a main voltage across.

This project should be economic though. Don't really want to spent so much money because this is a DIY solution.

I am living in Indonesia, the main voltage is probably 220 or 230.
johndough wrote:Hi

Somewhere earlier I posted something like this...

SOME SIMPLE RELAY KNOWLEDGE

Having worked with mains voltages, and lower, for about 45 years I want to attempt an explanation of how to control equipment etc with relays, digitally or manually switched.

These are my thoughts and views, and not a set of instructions on how to use any of the items or circuits mentioned. Mains voltage can and will KILL if allowed to.

My main relays of choice are Finder (http://www.findernet.com)and Telemacanique (http://www.schneider-electric.co.uk) both widely available from RS & Farnell just like a Pi.
Can you tell me which one is safe, durable, and cheap to use? I will only drive one to 4 light. Probably not more than 120W. I will put MCB to limit the current to 1A to 2A in the main (as opposed to 8A current insulation).

Image
I found a board with finder relay, it is as expensive as OMRON relay board. I hope I can just make it by myself rather than ready to use solution. Do you can refer some site that have high quality and simple schematic?
johndough wrote:The convention for naming relays and their terminals or contacts and connections will be:-

KR for a Relay and KM for a Motor rated relay. Coil connections are A1 & A2, for AC/DC.

In the case of multiple contact relays

Com Common 11 21 31 41
N/C Normally Closed 12 22 32 42
NB: Relays without C/O use N/O (13) (23) (33) (43)
N/O Normal Open 14 24 34 44
C/O ChangeOver
Pin Outs.PNG


Above is a 2 pole & 4 pole Change/Over relay connection layout. Using 8 & 14 pins, (3 pole C/O would use 11 pins). Next terminal numbers for an 8 relay board. Lastly a 2 N/O & 2 N/C block
Well, I totally don't understand at all. I am no electrical engineer, and probably this will be the first usage with relay. I only can wire simple light switch and simple electrical in house, but nowhere near to home automation level. Sorry about that.

From what I know, a traditional relay have 3 pins, NC, NO, and Common.
A SSR have 2 pins, NO, and Common.
johndough wrote:Now to veer off slightly and show a relay setup in conjunction with house lighting.
LightingMulti.PNG
The 3 electric lamps, L1, L2 & L3 shown above are controlled in various ways.

L1: Simply adding a relay contactKR1 (Normally/Open) driven by your Pi will remotely switch the light ON/OFF so long as the local switch is OFF.

L2: Allows ON/OFF locally &remotely (2 way switching) using a Change/Over contact of KR2.

L3: This more complicated circuit has a pair of 2 way switches, with an INTERMEDIATE switch added (you can add more intermediate switches) and a relay KR3 with 2 Change/Over contacts used to replicate an intermediate switch. Giving 4 switching points
L1 is probably a solution, but I cannot turn off the light if the switch is turned on. The manual switch will be used quite frequent as the relay only for automation, such as night time will turn on outdoor light, day time will turn them off.

I think the best solution is L2, where the I can control it by relay and manually, both on and off in the both switch and relay. I don't need extra switches, so L3 is not a right solution for me.

I need some circuit/relay to check the light is turned on or off, that is the problem that haven't being solved right now.
johndough wrote:Therefore adding a Double pole Change/Over relay in a box, controlled remotely by a Pi can switch Domestic house wiring. However it has huge potential risk if you are inexperienced and could damage you and/or your property.

DO NOT carry out any work that is in contravention of your local laws and/or regulations.

These are my thoughts and views, and not instructions, accessing cabling within a property could lead to injury or death for you, and damage to property.
I am not experienced at all, so I need more suggestion from the experienced people like you all. In Indonesia, automation system is very rare and probably non-existent. My budget is also quite limited, so I need some cheap but safe, durable, and dependable system.

I don't think there is regulation about this in my country. So there is no problem with local laws or regulation.

I will ask electrical installer to connect the cable safely to the relay board. Of course, I will not do it, as my experience is more like knowledge, not practical skill.
Tarcas wrote: Assuming that you're modifying a light and switch that already are wired, the main modification that you need are the two (L1 and L2) wires between the relay and switch. You can minimize their length by mounting the relay close to the switch, and reuse the wires that are already running to the power source and the light.

If this is a new light and switch, wire count doesn't matter. Running a 4-wire cable is no harder than running a single wire in most cases. Just buy cable that makes sense for your installation. Plus for a new install, you should probably be getting permits and would need a licensed electrician for that anyway.
I am modifying existing switch. So if the cable count can be minimized, that will be great.

Well, cable is quite expensive, as you need to run around 4x additional cable as existing installation. Running a cable is not really hard, just the cable is not cheap.

There is not permits needed here AFAIK (Indonesia) for all electrical installation.

johndough
Posts: 254
Joined: Sun Jan 13, 2013 2:00 pm

Re: [?] Light Switch

Sun May 04, 2014 11:31 am

Hi

Well I can hopefully help.

You need 2 relays with bases and a box to put them in.

http://en.indotrading.com/relay_166/

44 Series Page 55 Plug-In Pcb Relays Finder
[Feb 10 , 2014] Relay Price : IDR CALL Min Order: 0

Schneider Relay 230V 50/60Hz Available In Pd. Anugerah Sejati Is Located At Ltc Glodok Ug Floor Of Block C2 No. 2 Jakarta Indonesia
Price : IDR CALL

or something similar.

So if you can find a relay, preferably 2, I can "talk" you thru the install.
1 relay requires more cabling than 2, so you need to choose.

dlink377
Posts: 21
Joined: Thu Mar 21, 2013 3:34 pm

Re: [?] Light Switch

Sun May 04, 2014 2:17 pm

johndough wrote:Hi

Well I can hopefully help.

You need 2 relays with bases and a box to put them in.

http://en.indotrading.com/relay_166/

44 Series Page 55 Plug-In Pcb Relays Finder
[Feb 10 , 2014] Relay Price : IDR CALL Min Order: 0

Schneider Relay 230V 50/60Hz Available In Pd. Anugerah Sejati Is Located At Ltc Glodok Ug Floor Of Block C2 No. 2 Jakarta Indonesia
Price : IDR CALL

or something similar.

So if you can find a relay, preferably 2, I can "talk" you thru the install.
1 relay requires more cabling than 2, so you need to choose.
I prefer buying from RS-Component or Element14, especially Singapore site, as it is more feasible to buy from them rather than buying from local retailer.

Why using two relay have the less cabling than one relay? It should have more connection than one relay. I will use which one is more cheaper.

Actually, if this is economically possible, I want a relay that can be replaced easily when failure, such as DIN Rail type, as it is quite convenient, but it seems the cost is very high.

Can you suggest me which relay to buy from RS-Component for my needs? Both for single and double relay solution.

I already tried to search for some relay, I found this:
Such as: http://singapore.rs-online.com/web/p/no ... s/7761430/
It is so expensive, as the socket seems more expensive than the relay itself (http://singapore.rs-online.com/web/p/no ... s/4572846/)

If I buy this relay http://singapore.rs-online.com/web/p/no ... s/5085595/ and buy this bracket http://singapore.rs-online.com/web/p/re ... 428009|acc it is cheaper around SGD 7. But it is still quite expensive for me and the control voltage is 12V, I have no idea how to control it with Pi (only 3.3V)

This is the cheaper i find: Relay (http://singapore.rs-online.com/web/p/no ... s/0351601/) and Bracket(http://singapore.rs-online.com/web/p/re ... s/4004129/). It cost me SGD 11.39, still quite expensive but probably already feasible for now.

The Telemecanique doesn't have SPDT product as I need.

Please advise, I don't know which one to buy.

Thank you for your help.

boyoh
Posts: 1297
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: [?] Light Switch

Sun May 04, 2014 2:27 pm

dlink377 wrote:Hi,

After successfully controlling my TV, STB, and AC system with IR blaster, I want to improve my home automation Pi to control the light switches.

From what I learn I can just bought cheap 5V relay board from eBay and connect the wire directly. But this solution doesn't give any override / manual function in case of error in RPi. I also learn that I can use remote controlled bulbs, but that is quite costly and I cannot use standard switch.

I want a system that can be controlled with Pi and simple light switch. Pi can turn on and turn off the switch, so do the switch. I also take a look two terminal switches, but how the Pi know the light is turned on or off, and there is no two terminal relay available for cheap.

Any suggestion?

Warning, I suggest any con troll between the Pi
And electronics containing MAINS voltage
You use Opto Isolators , this will give you total
Isolation between the low volts and the mains
Voltage also noise feed back, Also you will have
No need to common the 0v (Ground)
Take great care when working with mains voltages
Unless you know what you are doing

On NO ACCOUNT connect the mains earth wire
To the Pi 0v Ground.

KEEP THE Pi TOTALY ISOLATED FROM
THE MAINS HIGH VOLTS
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: [?] Light Switch

Sun May 04, 2014 3:16 pm

5v dc relay, switches 240v ac
socket for 5v relay (if not wanting to put relay onto a circuit board).
Doug.
Building Management Systems Engineer.

dlink377
Posts: 21
Joined: Thu Mar 21, 2013 3:34 pm

Re: [?] Light Switch

Sun May 04, 2014 5:53 pm

boyoh wrote: Warning, I suggest any con troll between the Pi
And electronics containing MAINS voltage
You use Opto Isolators , this will give you total
Isolation between the low volts and the mains
Voltage also noise feed back, Also you will have
No need to common the 0v (Ground)
Take great care when working with mains voltages
Unless you know what you are doing

On NO ACCOUNT connect the mains earth wire
To the Pi 0v Ground.

KEEP THE Pi TOTALY ISOLATED FROM
THE MAINS HIGH VOLTS
I have no idea what is opto Isolators, I might have to do search on Internet about that first.

I will use relay, not connecting it directly to Pi. Also the one will connect the electrical component is experienced people, not me. I only provide the relay and they will connect it. I have no experience in that.

Well, I know Main earth wire and Pi Ground is different.

Thank you for your warning.
BMS Doug wrote:5v dc relay, switches 240v ac
socket for 5v relay (if not wanting to put relay onto a circuit board).
Well, the price is quite expensive for DIY like this. My budget is only like SGD 10 (Around GBP 5 / USD 8) each relay and the bracket. I don't want to solder it because no experience in soldering, especially main voltage. Also If I use bracket, I can change it easily if the relay is failing (is it possible a relay burned??).

I have tried to find few relay set on RS-Component that :
Relay http://singapore.rs-online.com/web/p/no ... s/0351601/ SGD 4.71
Bracket http://singapore.rs-online.com/web/p/re ... s/4004129/ SGD 6.68
Total SGD 11.39. However this is 12V, not 5V or 3.3V, I need additional circuit to drive 3.3V to 12V (a simple DC relay like 2N2222 ?? and a 12V power supply + 12V to 5V DC step down to drive the Pi)

This is the monitoring relay, I don't know if it's right or wrong:
Relay http://singapore.rs-online.com/web/p/no ... s/0140555/ SGD 6
Bracket http://singapore.rs-online.com/web/p/re ... 428009|acc SGD 5.37
Total SGD 11.37
However this is DPDT. I don't know it will work or not, and I think it is wasting so much space on the DIN Rail.
If DPDT can detect two different source (act as two relay), I don't mind, as SPDT version is more expensive.

However, both of them cost around SGD 25, it is also quite expensive. But since I am trying on 2 switch only for now, it would not hurt so bad. I also have to buy DIN Rail case, 2x two way switch, and many more accessories. Well, home automation things doesn't come in cheap. I am still thinking about PCB solder relay that only cost SGD 2.3 each (http://singapore.rs-online.com/web/p/no ... /7933768P/)

Any suggestion is appreciated.

Thank you.

dlink377
Posts: 21
Joined: Thu Mar 21, 2013 3:34 pm

Re: [?] Light Switch

Sun May 04, 2014 6:27 pm

I decided not to use Relay for monitoring the AC. I will probably use 5V Adaptor and step it down to 3.3V for Pi usage.

However, to find cheap phone adapter that have good quality to use 24hrs probably not easy at all.

Or maybe use AC small LED and a light sensor in a very small black box? The LED I mean like the one used in the power line that doesn't require any resistor, etc. I just don't know how to make it durable and safe. This probably the cheapest solution available.
But I heard that using light sensor will make your Pi CPU usage around 25%, CMIIW.

Any suggestion is appreciated.

Thank you

Tarcas
Posts: 740
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: [?] Light Switch

Mon May 05, 2014 3:03 am

dlink377 wrote:But I heard that using light sensor will make your Pi CPU usage around 25%
I don't see why it would. If the loop that you use to read the ADC includes a sleep statement (so it's not constantly running but takes a break after reading) it should be fine. You probably only need to read it before you switch the relay, right?
I decided not to use Relay for monitoring the AC. I will probably use 5V Adaptor and step it down to 3.3V for Pi usage.
That's actually a pretty clever solution. You'll only need that and a pair of resistors to make a voltage divider, I think. Plus of course the cable to connect it to the GPIO.
My budget is only like SGD 10 (Around GBP 5 / USD 8) each relay and the bracket.
If that's the case, I'd skip the solid-state relays and plan on them burning out every 100,000 cycles. If you're switching a few times per minute, it's only a few months. If it's only a few dozen times a day, that will last a very very long time.
Also rather than the brackets, a preassembled relay board is very cheap and easy to wire up. Something like this. I know I've seen people say "those aren't safe to use with mains voltages" but the relays are rated for 250v AC, so I would be absolutely flabbergasted if there aren't boards made using those relays that ARE safe, even if these aren't. Maybe they'll cost more than a couple of dollars, but they should be far less than your solid state + bracket. As a side note, the larger boards (2, 4, 8 relays) aren't much more than the size below, so it might be worth looking into getting a board with more relays than you think you need right now.

dlink377
Posts: 21
Joined: Thu Mar 21, 2013 3:34 pm

Re: [?] Light Switch

Mon May 05, 2014 3:56 am

Tarcas wrote:I don't see why it would. If the loop that you use to read the ADC includes a sleep statement (so it's not constantly running but takes a break after reading) it should be fine. You probably only need to read it before you switch the relay, right?
I think I will go with AC small LED and Light Sensor solution rather than relay or 5V adaptor. I think it is cheaper, can last longer, and quite reliable. It is only USD 1.5 for 20pcs (http://www.ebay.com/itm/20PCS-Photoresi ... 3a75b2a9d5). Do I need ADC or just use the technique here (https://learn.adafruit.com/basic-resist ... ll-reading)? I probably need to read it every access to light status and switch page. I don't know how to wire the AC LED safely and durable for few years.
Tarcas wrote:That's actually a pretty clever solution. You'll only need that and a pair of resistors to make a voltage divider, I think. Plus of course the cable to connect it to the GPIO.
Well, a good quality phone adaptor is like USD 5 (http://www.amazon.com/Motorola-Wall-Cha ... ds=Charger), not including the stepdown from 5V to 3.3V. This is also need huge amount of space (multiple charger).
If that's the case, I'd skip the solid-state relays and plan on them burning out every 100,000 cycles. If you're switching a few times per minute, it's only a few months. If it's only a few dozen times a day, that will last a very very long time.
Also rather than the brackets, a preassembled relay board is very cheap and easy to wire up. Something like this. I know I've seen people say "those aren't safe to use with mains voltages" but the relays are rated for 250v AC, so I would be absolutely flabbergasted if there aren't boards made using those relays that ARE safe, even if these aren't. Maybe they'll cost more than a couple of dollars, but they should be far less than your solid state + bracket. As a side note, the larger boards (2, 4, 8 relays) aren't much more than the size below, so it might be worth looking into getting a board with more relays than you think you need right now.
Well, I also thought that board is quite safe because so many people buying it and it is rated 250VAC 10A, but I won't take a chance that can do harm more than good. These board is so cheap (only around USD 1 each relay) that it is 10 times cheaper than modular solution with socket.

I want a permanent solution, rather than temporary one. To be safer, I will go with a more expensive solution that have dedicated bracket so I don't need to solder it myself (like this http://singapore.rs-online.com/web/p/no ... s/7943771/) and I can change the relay if it is reaching 8000 cycles (recorded in DB).

Thank You

Return to “Automation, sensing and robotics”