Monday 30 May 2016

Bathroom lighting

We are building a upstairs bathroom. In downstairs we already have the light controlled by a PIR sensors. Which works great, except at night. When you have to go to do your business half sleep and suddenly the lights go at full blast, good luck at getting to sleep after that. I need to have a way to make the lights only light very dim at night.

So basically the functional specification is as follows:
1. Lights on when someone enters
2. If it's night lights are dim.
3. If it's day lights are fully on.
4. User can manually force full lights.

Probably the most difficult was figuring out when it's night. A simple clock would only give moderate results because we don't usually go to sleep at a fixed time. I decided to solve the problem with a light sensor in the lobby where you enter the bathroom. If it's day then sun is shining in the lobby, if it's evening and dark outside but you have the lobby lights on then you are not sleeping and want full lights.

There are three led strips for lighting, and most likely one of them is behind the mirror, they should all be separately controllable to give optimum lighting.

Pir sensor is just a standard mains voltage pir sensor that switches on the power source that powers the led strips and arduino.

Full light switch is also a normal mains switch that switch on power source source and gives a signal to arduino that full light is requested.

For the light sensor I chose TSL257, because I had one lying around and it has linear light to voltage ratio. Power source is just some generic power source from aliexpress.  Because the led strips are 24 volts I had to get that down to acceptable level for arduino, for that I used a generic stepdown converter, again from aliexpress. If I used 12 volt led strips I could just use that straight to power arduino. Full light switch gives mains voltage so that needs to transformed to a suitable voltage for arduino to read, an old cellphone charger is fine, just to make sure it gives a voltage below 5V I will put a zener diode in there, and also a bleeder resistor so it doesn't stay on for too long after the power has been cut off.

For some reason I have problem with the TSL257, when it's on a long lead it doesn't give correct results for some reason. Which is odd because I have one looking at pulses from our electricity meter and it works just fine with a long wire.

I also put a possibility to set the full brightness, which was nice because two led strips about 2,7 meters long where way too bright.

I have made the controller to veroboard and it seems to function, it hasn't been installed permanently yet because the mains wiring isn't done yet. I'm not an electronics engineer so this might look somewhat ugly:) In the few days it has been in use I already found a bug, I didn't put any hysteresis in the dark/light sensing part of the code, so in the correct lighting it flickers somewhat.


Current code https://github.com/mika-koivusaari/bathroom_light_controller

I'm in the process of making a schema with Fritzing but I have to first find or make TSL257 for Fritzing.

No comments:

Post a Comment