0
\$\begingroup\$

I found a great circuit for light home automation: circuitdb.com, but I would like it to be more than a momentary light switch bricked up in the wall.I would like to control it by raspberry or arduino.

enter image description here

How must this circuit be modified to send light status to raspberry and from the raspberry to the enable relay? Connections between raspberry and circuit would be made by a UTP wire. I want to add a 230V relay.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Why not just do the switching with raspberry? Why do you need 4017 IC? \$\endgroup\$
    – Golaž
    Commented Jul 27, 2015 at 15:34
  • \$\begingroup\$ @Golaž I wanted to make autonomic units and reduce wires, but maybe that's a good idea, thanks :) \$\endgroup\$
    – luzny
    Commented Jul 28, 2015 at 13:13

2 Answers 2

1
\$\begingroup\$

The purpose of the 4017 IC in this circuit is to "remember" whether the relay should be on or off. If you control the relay using software in a microcontroller (an Arduino, Raspberry Pi, etc), then you can simply store that state in a variable in the program instead. The 4017 IC is used here as a one-bit toggle-able memory and can be replaced by the microcontroller.

That way, you also don't need to "send the light status" to the microcontroller, since the microcontroller is the device that gets to decide the on/off state, and thus already "knows" the state.

The only parts of the circuit you need to keep are:

  • The relay, of course.
  • The snubber diode connected in parallel to the relay (important).
  • The C1 decoupling capacitor (C1).
  • The transistor and its base resistor (R2).
  • Optional: The indicator LED and its current limiting resistor (R1).

You connect an output pin from the microcontroller to the base resistor, replacing pin 2 of the 4017 IC.

The 4017 IC, D2, C2, C3, R3 and R4 can then be removed.

For information about how to choose the transistor and the base resistor, I recommend Ben Krasnow's excellent video tutorial: https://www.youtube.com/watch?v=8DMZSxS-xVc

If you want to keep the button

You can also keep the button. In that case I would recommend connecting it to an input of the microcontroller. You also need to debounce it, either in software (very easy) or using extra hardware components. If you debounce it is software you would typically connect the button between the microcontroller input and the positive microcontroller power supply voltage (3.3 V or 5 V, not 12 V!), and also connect a pull-down resistor of about 10k Ohms between the input and ground.

What pressing the button does (eg. toggle the relay) is then up to the software.

\$\endgroup\$
0
\$\begingroup\$

I can't yet comment, but keeping autonomous control is a GOOD thing, to which you can then add automation. You really don't want the situation where the RPi goes down and then you're stuck in the dark.

That said, communicating reliably and safely over a distance can be difficult. Opto-isolators are probably your best bet. You really don't want electrical noise creeping into your home automation, causing spurious activation. Or worse, shock or fire hazards.

Two twisted pairs (of the three available in even the cheapest CAT3 phone cable) could be used. One (to the RPi) feeding the LED side of one opto from the relay drive, and one (from the RPi, which drives the LED side of the other opto) coupled across your momentary switch.

The RPi would then have the current status of the relay, and could 'push' the switch at its discretion. The RPi and your toggle switcher would be electrically isolated.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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