DXXPublic
Posts: 5
Joined: Sun Apr 05, 2015 12:44 am

Beginner needs help with light control

Fri May 22, 2015 10:24 pm

Hi all,

Im currently working on a home automation project and ive came across a roadblock and hopefully someone can tell me if what i want to do is possible and maybe point me to the right direction.

This question is specific for controlling lights using a relay (the cheap way). Let me explain you the details:

Parts:
Raspberry Pi Model 2 using Domoticz software
2 Channel 5V Relay Shield Module
Dual single pole wall on off toggle switch
Dual three way wall on off toggle switch

Goal: Control the lights manually and also tru the relay.

Ok, so far this is what i have done.
Using the 3way toggle switch, I followed this guide: https://en.wikipedia.org/wiki/Multiway_switching and i was able to make it work. I can switch on and off the light from the manual toggle switch and i can turn on and off the light from the relay (controlled by the Raspberry Pi)

Ok, so what seems to be problem then... The software im using to control the relay from the raspberry is Domoticz, and it only reads the state of the relay (or the gpio), if its on or off and reflect that status visually on the software. The situation is when for an example, i turn on the light manually, on the software will appear as off, and if i turn it off on my software then it will appear as on and so on, so basically the state of the light on the software is all messy all the time.

Is theres any way, where i can change the state of the relay when turning on and off the toggle switch? And also control the relay trough the raspberry? Is theres any other alternative to my situation that can be applied here? I want to be able to control the lights from the manual switch and the raspberry also, but that it display the current status on the software

Thanks in advance

venom
Posts: 13
Joined: Sun May 17, 2015 8:55 pm

Re: Beginner needs help with light control

Fri May 22, 2015 10:40 pm

im a beginner as well and seeking assistance with some of my projects as well..... with that said invision this im not going to write it in code but in thaught pin 1 = gpio 17 relay 2 = gpio 20.......place a while statement in your code stating while pin 1 is on turn on relay 2 then while pin 1 is off turn relay 2 off wait for command on pi for relay response so if pin 1 in input and relay 2 is output then you should be good to go

DXXPublic
Posts: 5
Joined: Sun Apr 05, 2015 12:44 am

Re: Beginner needs help with light control

Fri May 22, 2015 10:51 pm

Thanks Venom, but maybe i didn't explain myself correctly.

The main question basically is if there is a way of controlling the state of the relay trough the wall toggle switch, so i can always have an accurate light state on the software.

venom
Posts: 13
Joined: Sun May 17, 2015 8:55 pm

Re: Beginner needs help with light control

Fri May 22, 2015 11:08 pm

yes there is by routing the wall switch into the pi's gpio as input then have the relay as output on gpio and with the code writen as while gpio input is true make gpio output true while gpio input is fals make gpio output false else wait comand from the pi itself

DXXPublic
Posts: 5
Joined: Sun Apr 05, 2015 12:44 am

Re: Beginner needs help with light control

Fri May 22, 2015 11:16 pm

I guess i have to look into "routing the wall switch into the pi's gpio"

Ramesh.Kanthasamy
Posts: 2
Joined: Sat Sep 19, 2015 9:16 pm

Re: Beginner needs help with light control

Sun Sep 20, 2015 7:47 am

DXXPublic wrote:Hi all,

Im currently working on.............

Is theres any way, where i can change the state of the relay when turning on and off the toggle switch? And also control the relay trough the raspberry? Is theres any other alternative to my situation that can be applied here? I want to be able to control the lights from the manual switch and the raspberry also, but that it display the current status on the software

Thanks in advance
Yes definitely
In simple terms you have to tell your Raspberry that you are bypassing it and changing the state of the output (i.e Raspberry GPIO pin is on so that the relay is on. You switched the lights off but there is no communication between the switch and Raspberry to pass the change of state)

See there is a way to introduce a control board in between which can manage the ligths and all you then have to do is to check the state of the pins on control board and change if necessary.

Voltage on control boards pin should change if the state of the lights chage. This means that your manual switching should go through the control board. So that someone is in control at all times.

Somehow you have to feed back the current state of the light to your program.

Please let me know if you need any clarification.
Hope it helps !

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

Re: Beginner needs help with light control

Sun Sep 20, 2015 11:26 am

Hi

To control a light with a Pi, you can either fit a multipole relay or try a Telerupteur with a relay.

viewtopic.php?f=37&t=103309&p=735567&hi ... ht#p735567

May give you an idea.

http://www.schema-electrique.net/schema ... laire.html

So what else can I try and help with?

Slackware
Posts: 131
Joined: Mon Jan 18, 2016 3:45 pm

Re: Beginner needs help with light control

Sun Feb 14, 2016 4:06 pm

A light sensor should also work. light is on it would trigger the sensor. Or run switch to the pi, and it will ALWAYS be the one turning light on and off. person won't know the difference, they move the switch light goes on or off.

Return to “Automation, sensing and robotics”