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:
That's not to say the photoresistor can't be made to work 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:
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
Working in poorly lit conditions comes with a whole heap of challenges. Have you ever accidentally drilled the wrong part of a wall? Tripped over your toolbox and had it spill its contents all over the shop? Perhaps something as simple as walking into tables in your workshop has gotten the frustration going? If you’ve experienced any of these unfortunate events, then you should keep reading and check your work lights!
Learn More: (https://hokolite.com/a/blog/best-led-work-lights)
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem