(This is based on an idea by Ard Jonker, who planted a seed and watched the coin drop, if you excuse the mixed metaphors…)
The recent experiment with direct relay switching suggests that it is possible to switch a latching relay with just two I/O pins tied together plus a 100 µF cap.
The thing about that circuit, is that it draws no current in either ON or OFF state – it only needs a little energy to change the state.
That means it could in principle be powered by a very low-power source, such as this other fun projects I had to shelve a while back. The reasons for this remain as valid as ever: I can’t realistically turn this into a safe kit, given the direct connection to AC mains. So while the thought of having 80 of these sprinkled around the house and consuming under 1 Watt total is a tempting thought, it just isn’t going to happen.
Which doesn’t prevent ME from using it anyway, of course…
Ok, now let’s bring a couple of components together:
- a JeeNode Micro
- a 12 mW AC mains supply
- a directly-powered latching relay
- a toggle switch
- power cabling
Here they are, with a nice plastic case (whoops, forgot to include the JNµ, oh well):
The toggle switch is the small but essential ingredient here. Let me explain:
This is a switch which can be operated manually and remotely. Flipping the switch or the relay has the same effect: toggling power, regardless of the state of the other component!
This means it can be operated even when the automated system is off or disconnected, or has crashed. And likewise, the power remains under remote control regardless of the state of the manual toggle switch. This solves a key problem with all those cheap remote power switches out there: the necessity to find the remote, because there is no local switch anymore. And the fact that it breaks down when the home automation system fails.
Given the relay used, I doubt that this solution will be able to control more than 30..50 W, but there are plenty of such devices around the house these days, even LED lighting.
I think I’m gonna have to start messing with AC mains again… with caution, of course.
Can the JNu detect the state of the device, so that it can turn the device on or off whatever the state of the manual switch?
Hopefully, yes – that’s the reason for the 0.1Ω sensing resistor.
FWIW, the FS20 remote power switches I have (not the cheapest kind, but not too expensive either at around 60 euros for 3 switches + remote) have a button on each switch for manual control. The only problem with them is that they forget their state if power is lost. This circuit would fix that.
And they are uni-directional: when you press that button, the central system doesn’t know (all it can do, is try and listen to the commands from the remote as well).
When you are in low-power (uA) range with your micro, you might consider a photovoltaic optocoupler as a power source. That’s an optocoupler with pv cells instead of a photodiode. That gives you around 50uA@7V galvanically isolated from mains, which makes debugging with a scope easier and feels safer :) They are rare, though. Here’s one: http://www.farnell.com/datasheets/90904.pdf
Have the JeeNode throw its relay and do the hallway circuit with a physical switch (low power wiring) sitting next to the JeeNode doing motion and light detection. Power relay (opto-isolated) does the heavy lifting. Centralised power supply for all opto-isolator LEDs also feeds JeeNode. Manual switch overrides JeeNode/HA and the circuit will still work if HA fails completely. SAF happy.
great idea~! curious about the resistor- are you merely watching for usage or are you looking at current/power usage?