Wardrobe lighting problem

Posted on
  • Hello,
    I've installed LED strips in my wardrobe and using Espruino and a Photoresistor the LEDs turn on of off when the door is opened/closed. All the wiring and code works perfect, the issue I have is more funny.
    Wardrobe door opens and sun/room light hits the photoresistor, Espruino reads this and turns on the LEDs. All good so far.
    The problem is when the doors close. The LEDs light up the inside so much the photoresistor doesn't detect a large enough drop in light to turn off the LEDs. :(

    I've tried many different light values and code to guess when the door is closed but every fix has side effects. Should I try looking at using some other sensor to detect the doors opening/closing? Reed switch, motion sensor, ...
    My wardrobe has two sliding doors that over lap making it a little awkward.

  • That's quite a fun problem :)

    A reed switch would be better for some other reasons:

    • What happens if you open the Wardrobe when it's dark?
    • It also allows Espruino to 'sleep', and to wake only when the reed switch changes state. At the moment it'll be having to check the photoresistor every so often, which means it'll be using more power. If you're not running off a battery maybe you don't care though (and if you are you may find that the LED strips draw a bit of power even when off)

    That's not to say the photoresistor can't be made to work though...

    What about:

    • Put the photoresistor in a small cylinder (a cut up biro?) that faces the door. That way when the door is closed, light from the LEDs shouldn't make it think it's light outside.
    • Check for two separate values for when the lights turn on, and when they turn off - and make sure the lights turn off when there's more light than when they turn on, to take account of the fact that the LEDs are lit up (you'd have to add a delay to give the LEDs time to light up before you turn them off though :).
  • Another sensor you could use is an IR reflectance sensor. You can then put a white label on your sliding door which will reflect the light back when it's closed. It might be easier than mounting a magnet on it.

  • I've been think about a reed switch as it doesn't rely on outside light but I'm not sure if the magnet will be close enough to activate it. Because the doors overlap the magnet would be about 70mm away. I might buy it anyway to try.

    I'll try the cylinder cup idea. Simplest solutions are normally the best.

    I tried have conditional values to turn the light on and off but this led to rave like effects where the lights would randomly turn on/off and not turn on/off depending on the room light.

    The IR sensor would be great but a little more costly I'd guess.

    I'll let you know how each option goes.

  • 70mm for a reed switch is pretty damned far - I doubt this will work unless you're able to get one part of it in closer (maybe the reed part on the closet side, right next to where the door travels, and a beefy magnet on the door?). I use reed switches, and found I needed to get the magnet (a rectangular rare earth one of considerable strength) like 1 cm away from the switch for reliable operation - though my reed switch might be less sensitive than some?

    I see a few options:

    1. Reed switch, with some bit of cleverness to get the magnet and switch mounted.
    2. LDR in the bottom of a can or tube facing out and located close to the door. This, of course, will present a problem if the lights outside the wardrobe are off, but you still want light to find things inside it, though I'm struggling to think of a case where this would matter. In any event, like any sort of light sensing, the exact position of the sensor, and the size, shape, and orientation of the light-shield around it will make a big difference.
    3. Physical switches, probably a micro-switch of some sort. (wouldn't this be a good use for one of those micro-switches with the roller-wheel on the end of the arm? Or are those scarce/expensive if you don't have them on hand?)
    4. Use a PIR motion sensor, on the reasoning that things rarely move inside a wardrobe while the door is closed. Of course, you'd need to give it some grace period, otherwise you'd have to dance and wave your arms while choosing what to wear.
  • There's a very small amount of info on the IR proximity sensors here. They came with the Ultimate Espruino KickStarter kit, but I haven't done any tutorials with them.

    They are pretty cheap to buy though, if you decide to go that route.

  • Update: I've got it working with IR proximity sensors. It's not 100% perfect as the overlapping door is a little bit too far away to get accurate readings and bright sunlight can affect the readings. But I think I can correct it with code modifications.
    If I where to do this project again I think I would try with some coiled spring switches like: http://tinyurl.com/ountcx4

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Wardrobe lighting problem

Posted by Avatar for Owen @Owen