Failsafe for home automation with Raspberry Pi

home-automationraspberry pi

I have a Raspberry Pi driving a home automation system. I have connected a bunch of lights to the network. The GPIOs of the Pi connect to a relay board that switch the lights on and off. What I need is failsafe + alternative switches. These switches need to work even if the Pi fails, and they need to be usable when the system is operational (in 3 way switch, Pi switch XOR manual switch = bulb state fashion).

What is the best/standard solution for this? Three way switches would work, but then the Pi loses the state of the devices. I could get the state of the lamps by setting up a DC adapter in parallel to the bulb input, effectively measuring voltage which could feed back to the Pi telling me the true state of the bulb.

Best Answer

You could use light sensors giving feedback to the rPi about its state. Or use some small value resistors (sense resistors) to tell the rPi if there is current flowing to the lamps. Hall effect sensors on a lead to the lamps could also detect current without the power loss that a sense resistor would incur. Each of these could determine state. In software, you could control the relays depending on the desired state versus the detected state.

The alternative power could be provided by a normally closed relay whos coil is powered from the rPi's power. If that was lost, the NC relays could introduce power to the lamps from an alternate feed(backup). When the pi came back online, it would then OPEN the NC relays now letting you KNOW the state of the bulbs is OFF and the rPi would continue on its original program. A single pole switch in line with the backup relay and the bulb would allow you to manually control power.