2

My first project with my raspberry is how to control the home lights, all of them. What I want is to have the ability to turn on and off each individual light. I know using manual switches won't work, because if I turn off a light, the switch would stop working (manual functionality). So I am searching for some switch I can connect to the Raspberry, do you know which seitch I have to buy?

EDIT: What I want to achieve is that I can turn on/off the lights from the raspberry without disabling switches when I do it.

  • What does it mean that a manual switch would stop working? – RalfFriedl Jun 25 at 5:52
  • I mean, if the rele connected to the raspberry did turn off the power, the light won't fire uo when you activate the switch (manually). Am I wrong? – Javier Torron Diaz Jun 25 at 5:57
  • Hello, so you want an "exclusive or" arrangement where either the Pi or the normal wall switch can control the light at any time? Would you want the Pi to also know if the the light is on or off? – Roger Jones Jun 25 at 7:33
  • I want both, switches and raspberry must turn the lights on/off. And of course, if possible It would be great if the Pi knows the lights state. – Javier Torron Diaz Jun 25 at 11:14
1

You could achieve this with an "exclusive OR" (or XOR) gate and some feedback from the manual switches to the Pi (so it can adjust it's output when you manually change the light state) but if this is the case then you might as well drive the lights from the Pi all the time and treat the manual switch as an additional input to the Pi that should be combined with the external request by the software (via WiFi or whatever):

schematic

simulate this circuit – Schematic created using CircuitLab

As we're dealing with mains voltages you will need to ensure that you, your house and your Pi are safe and legal -- if you are not sure how to do this then pick a different project or educate yourself first. Note that this is just a rough outline, you'd need all sorts of isolation and protection here to prevent damage or death. I repeat for emphasis: dealing with mains voltages should be done with care, it's up to you to know what you are doing.

Given the above you might be better off looking at some of the commercially available modules available, such as Sonoff or Crownstone.

  • 1
    Thanks a lot for your help. Your diagram is incredible! You solved me a lot of search. Dont worry about main voltages, I will pay a professional for the main voltages part. – Javier Torron Diaz Jun 25 at 19:00
  • 1
    I dont want to buy a commercial module, bacause I am introducing into learning IoT, and wanna do it by myself. As I said I will pay a professional worker to install wires etc. So you are saying that this can be done with manual switches, right? – Javier Torron Diaz Jun 25 at 19:03
  • 1
    I'm saying that you need to find a way of safely reading the switch state on the Pi so it can decide if the lights are on or off. Note also that, if the Pi breaks or your software crashes, you'll have no control over the lights, even with the switch. Welcome to the world of compromise :) ! – Roger Jones Jun 26 at 7:05
  • 1
    Thats why I was sying that the switch need to be enabled all the time, even when the Pi is down or the software crashes. I understan the XOR gate purpose, but it would be better if we use smart switches instead manual switches, dont you think? – Javier Torron Diaz Jun 26 at 9:50
  • @Roger Jones, (1) I am jealous that your drawing is colourful. I know how to colour text, but did not know wires can also be coloured. Must try later. (2) My new toy SonOff just arrived. Should test soon. (I have a long list of unread books, and even longer list of unplayed/stalled toys/projects! :)) (3) I also admire your understanding of the OP's greedy user requirements. I did read his question a couple of times but did not catch it, wrongly thinking that his English is broken. Actually it is my head that is broken! :) – tlfong01 Jun 27 at 3:23
0

Question

How to control home lights, turn on and off each individual light, ...

Answer

Well, there is a type of manual switches called DPDT (Double Pole Double Throw) which lets you turn on lamp upstairs and turn it off downstairs, and vice versa. You can also DIY Rpi versions using relays.

up_down stairs switch

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.