My guess is that the sensor works as described in this article by measuring current induced by the photodiode when exposed to light. From that article:
As a photodiode, an LED is sensitive to wavelengths equal to or
shorter than the predominant wavelength it emits.
That would explain the choice of the red LED - it detects more of the spectrum than the other LEDs. The article also notes the following:
To use the LED as an optical detector, do not forward bias the LED
into quadrant #1 of the current-voltage (I-V) curve. (Quadrant 1 is
when the operating voltage and current are both positive.)
So, there you go. Don't turn it on.
For the simple night light project, I ended up using a second Puck as the ambient light sensor to turn the puck acting as the night light on and off. This is a decent work-around but certainly could be less than ideal for many projects.
It is unfortunate that maintaining accurate light sensor readings looks like it requires sacrificing physical feedback on the puck, at least using whats on board. One possible solution in some situations could be to use the load function, which restarts the puck and reloads the script from flash. According to the docs load() does not perform a full hardware reset, but it might reset the light sensor readings.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@allObjects @Ron
My guess is that the sensor works as described in this article by measuring current induced by the photodiode when exposed to light. From that article:
That would explain the choice of the red LED - it detects more of the spectrum than the other LEDs. The article also notes the following:
So, there you go. Don't turn it on.
For the simple night light project, I ended up using a second Puck as the ambient light sensor to turn the puck acting as the night light on and off. This is a decent work-around but certainly could be less than ideal for many projects.
It is unfortunate that maintaining accurate light sensor readings looks like it requires sacrificing physical feedback on the puck, at least using whats on board. One possible solution in some situations could be to use the load function, which restarts the puck and reloads the script from flash. According to the docs load() does not perform a full hardware reset, but it might reset the light sensor readings.