A couple of months ago a friend showed me his plans for a new bathroom in his house. The plans included a number of electrical items – fans, lights, etc – all of which required switches.
The problem is that – in the UK at least – there are tight regulations around electrical switches in the bathroom. Two standard solutions are to either have all switches outside the bathroom door, or have ceiling-mounted switches inside controlled by pull cords.
Neither solution was ideal – having to leave the bathroom to change the lights isn’t great, and the number of different electrical items made pull cords impractical (they’d need at least four cords in the corner of the room and it’s unlikely any guest would be able to work out what did what.
I proposed a solution using infra-red proximity sensors mounted underneath a sealed glass shelf. I then got to work on a prototype which is shown in the video below.
And here’s the finished product in position – the blue LEDs show that the switches are off and gives visitors a clue where to wave their hands.
The system uses four IR proximity sensors (approx £5 each) linked to an Arduino Uno. The Arduino is hooked up to a Sainsmart 4-way mechanical relay capable of switching mains voltage at up to 10 amps. Also linked to the Arduino are four RGB LEDs. We’re using the blue and red inputs on each LED to indicate the on/off state of each relay.
Controlling the switches is pretty straightforward. The proximity sensors project a fairly narrow beam directly above, allowing them to be mounted fairly close together without problems. They also have an analogue distance adjustment, controlled by a screw on the underside, which determines how high above themselves they can ‘see’. To switch the relay on or off you simply pass your hand 0-15 centimetres above the relevant IR sensor.
I’ve written an Arduino sketch that does some basic checks and ‘de-bounces’ rapid flickering hand movements so the relays aren’t triggered on then off again say by two fingers that are slightly apart.
Here’s a basic breadboard schematic of the setup (click for full size):
The Arduino sketch is available on GitHub. UPDATE: This new version of the code (Dec 2013) is much more reliable, both because it more sensibly debounces user input, but also because it uses the little-know Arduino Watchdog functions. https://github.com/grantgibson/ir-switch/
And here are the switches turned on:
Important disclaimer: I have no electrical qualifications. I don’t even know if this system meets wiring regulations for bathrooms (or any room for that matter). It’s just a prototype I built for my own amusement. If you try to follow my method you assume all responsibility for anything that goes wrong or right. Remember – mains voltage can kill.
If you have any questions – or if you build your own system based on this blog post – please contact me.