2

I'm trying to measure the light in a room with a simple circuit: a phototransistor connected in series with a resistor. An LED strip changes brightness according to the brightness level in the room.

The problem here is that the phototransistor also picks up the light from the LEDs. It is not an option using an IR phototransistor because I also need to measure the light from the room's light bulbs. Also, because of the device's casing, I need the sensor to be surrounded by the LED strip. Finally, I tried turning off the LEDs before measuring does not seem to work, as either the Arduino or the sensor is too slow, to turn off, perform the measurement, and turning back on the LEDs, without a human eye perceiving it.

Is there any standard or well known solution to this problem?

I will appreciate any help you can provide.

Additional Information

The LED strip is the WS2812B. The phototransistor I'm using operates between 420 nm and 1130 nm, with peak sensitivity around 850 nm.

Furthermore, to specify the functionality I'm trying to achieve: whenever the room is dark, I want the LEDs to be not too bright. If the room is too bright, I want the LEDs to shine brighter as well.

  • 3
    do not measure brightness with LEDs off .... measure the overall brightness of the room and adjust the LEDs to keep it at a set level – jsotola Jun 13 '18 at 16:14
  • 1
    Can you add some more information such as the LED strip you're using, and the photodetector? – BobT Jun 13 '18 at 16:14
  • Put the phototransitor in a tube so you can direct where the light can come from. Point it away from where the leds point. But I think you should look into your failed solution some more. Try playing with the value of the series-resistor. Try it with just a single led instead of a whole strip with mosfet(?), to figure out which is the culprit. – Gerben Jun 13 '18 at 19:56
  • @jsotola, thank you very much. The issue, which I failed to mention, is that I don't want to keep the overall brightness at a certain level. What I wish to do is to have the LEDs to shine bright if the room is very bright, and to lower their brightness if the room is dimmer. – David Jun 14 '18 at 12:01
2

Normally you should be able to switch LEDs off, make a measurement and switch LEDs back on without a noticeable delay. Brightness variation is noticeable below 100Hz, which translates to 10ms period.

What you need is a photodiode with fast response time (under 0,1ms or so, though there are devices responding in nanosecond range). Phototransistors and LDRs are considerably slower.

LEDs response time is in single-digit microseconds even for white LEDs, and RGB LEDs are even faster. Below is a response of typical LEDs to a 200ns pulse:

enter image description here

Regular AnalogRead takes about 0.1ms (and, again there are faster alternatives), so you can easily achieve kHz measurement frequencies where brightness variation is completely unnoticeable.

  • My favourite answers are always "Have you tried turning it off and back on again" – Joe S Jun 14 '18 at 12:43
  • 1
    Thank you. I did some timing tests, and I think the issue here is that the LED strip is relatively slow. To control it I use the FastLED library. – David Jun 14 '18 at 12:43
  • @DAVID You could make a "kill switch" for all LEDs in the strip with a BJT/MOSFET which you'd drive directly from a pin. That should be sufficiently fast. – Dmitry Grigoryev Jun 14 '18 at 12:49
  • @DAVID Alternatively, try to shield the phototransistor from direct LED light, maybe you get it working as is, without toggling the LEDs. – Dmitry Grigoryev Jun 14 '18 at 12:58
0

What you can try is to use a color sensor. Since you know the color of the LEDs you control, if the color sensor picks up a different color, you know it is because of other light.

Since this is not full proof (ambient color might be exactly as the LED color), you can check color differences (also with a non color sensor). If it differes without you changing the LED, you know there is ambient light (either increasing/decreasing).

It also will help if you put the sensor in a tube which is in a different direction than the LEDs to prevent as much as possible picking up the light from the sensors if possible.

(if you don't have color sensors you can use a normal sensor with some colored plastic above/around it).

  • Thank you very much, I will try this. However, in the long run I would like to be able to change the LED strip's color, so I guess using a color filter would not help in this situation. – David Jun 14 '18 at 12:11
  • In that case you need an RGB color sensor, or 3 LEDs with a red, green and blue 'filter'. – Michel Keijzers Jun 14 '18 at 12:12
  • Ahh, perfect. I didn't think about it. Thank you very much. – David Jun 14 '18 at 12:23
  • Good luck with your project. I also might use something similar myself. – Michel Keijzers Jun 14 '18 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.