I'm doing a feasibility study for automating the lighting in our house (eg. with Home Kit), while keeping the existing light switches fully functional.

With regular switches, that would be tough, however, we already have a centralised, yet analogue system: Several dozens of low voltage push buttons with indicator leds are spread across the house. These are all physically wired to latching (bi-stable) relays in the central fuse box (this type). So with a short button push, a low voltage pulse is sent to the relay, which will make it flip state and holds that. Multiple buttons can be wired in parallel to the same relay. The relays are bi-polar, so that all corresponding indicator lights follow the state of the light.


simulate this circuit – Schematic created using CircuitLab

To add automation on top of the existing functionality, I suppose we would need to replace the latching relays in the fusebox by a multi-relay raspberry pi system. It must be controlled both from HomeKit commands, as well as from physical push buttons. The relays would also have to bi-polar to control both the lights and the indicator leds.

My questions:

  1. For every light, I would need an output pin (relay) AND an input pin (switches) on the GPIO. Is that correct? Will the raspberry HomeKit software be able to simulate latching behaviour from the input pins?

  2. Bi-polar relay boards are hard to find. As a workaround, would it be possible to split the output current of a single GPIO pin to drive 2 relays? (Assuming a powered relay board with opto-couplers) ?

  • Welcome to Raspberry Pi! Please take the tour and visit the helpcenter to see how things work here. It would be helpful if you could figure out more details of your relays and edit that information into the question - make and model of the relay and if possible some insight into its current wiring, e.g. the push buttons and the indicator LEDs.
    – Ghanima
    Dec 27, 2016 at 10:39

3 Answers 3


To me it seems a lot easier to connect the pi outside your existing relay - essentially making the pi work as just another switch in parallel with the other ones on the circuit you want to control.

This way you can use your existing bi-polar relay board.


simulate this circuit – Schematic created using CircuitLab

This will save you the trouble of operating high-voltage circuits as well.

  • 2
    Depending on the type of the relay (both w.r.t. the voltage and current it needs to switch) it might still be necessary to use a transistor with the Pi to drive the relay (as shown here raspberrypi.stackexchange.com/a/28201/19949 - that circuit however might not apply to all types of pulse triggered relays)
    – Ghanima
    Dec 27, 2016 at 9:56
  • Interesting idea! But how would the Raspberry know the current state of the lights? Dec 27, 2016 at 11:30

Circuit that use the system of low voltage push buttons and latching relays usually come with a transformer or small power supply, e.g. 5V DC or 12V DC (but other voltages are also not uncommon such as 24V as pointed out by the edited question). There are also models available with low or high pulse trigger, that is, the push buttons are either providing a contact to GND or to the control voltage. It is necessary to determine this before proceeding to wire some additional circuit in parallel to it.

A simple solution is to have the Pi trigger the relay in parallel to the existing push buttons as Bex' answer describes but with a transistor to accomodate for the differing voltage levels of relay and Pi.

Assuming the relay uses a "high pulse trigger" as suggested by the added schematics in the question a high side switch is required to simulate this pulse with the Pi. This question at EE.SE shows how to do it. The node "6V" is replaced with your +24V, "GPIO" is your Pi's output pin, and the node "IC Vdd pin" goes to the relay in parallel with the push buttons - though I am pondering whether an additional diode in series is necessary to decouple this circuit from any feedback if the push buttons are pressed.

enter image description here

Source: https://electronics.stackexchange.com/a/90326/52154

If the relay would use a "low pulse trigger" an open-collector transistor could look similar to this - wiring the collector to the input of the latching relay in parallel to the push buttons.

Reading back the status of the indicator LEDs could be as easy as placing a pull-up resistor in parallel to the LEDs (between the terminal of the relay and +24V), e.g. R1 = 47kOhm (higher than listed in the example due to the higher supply voltage), and connect via another resistor to the Pi's input GPIO pin (as pictured here).

enter image description here

Source: https://www.raspberrypi.org/learning/physical-computing-guide/pull_up_down/

  • I get the idea. The Pi would be inserted in the existing system as if it were yet another light switch with indicator light. It would require 2 GPIO pins per light. Dec 28, 2016 at 23:02
  • But question remains if the homekit software can already handle this kind of switching. Or would extra development be required? (eg. A new Homebridge plug-in) Dec 28, 2016 at 23:12

Thank you Bex and Ghanima for the suggestions. You motivated me to keep experimenting until it worked. The question got >1000 views so I better share my working design:

Correction: 24VAC

First a correction: The indicator leds and latching relays are actually on 24V alternating current. This added some extra complexity.

Input Circuit

To read the 24VAC signal that was meant for the indicator LED's, I used a diode and capacitor to rectify and smoothen somewhat. The resulting DC signal triggers an optocoupler which drives the GPIO input pin.

Output Circuit

To send pulses to the latching relays: The GPIO output pin drives a transistor, which creates enough current to trigger a small relay which can switch the 24VAC.

the input and output circuit


Thanks to the optocoupler and small relay, the microcontroller is galvanically isolated from the outside world.


In the end I didn't use a raspberry, but an ESP32 microcontroller. This one has enough pins to control 12 lights. And with MaximKulkin's HomeKit implementation and some custom code, I could integrate with HomeKit over WiFi.

Board Design

The microcontroller, 12 inputs units and 12 outputs units fitted on a single strip-board the size of a shoe box. Here's my board design. It costed me about 60$ to build (including the microcontroller).


Now I can control 12 lights from my phone/tablet but also still from all the existing wall switches.

(see here for a short demo).

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.