I'm wondering if it would be at all possible to use a Raspberry Pi camera (attached to a Pi 3) to read the ambient brightness of the environment, as a light sensor.
I would want to poll the sensor once every 1-5 seconds such that I can adjust a variable based on the value of brightness seen. Something resembling...
var run = setInterval(function() {
var ambient = <code to read the RPi brightness>;
if(ambient < 100) { doSomething() }
else { doSomethingElse() }
}, 1000);
I have seen the following Node-based and javascript controller, but haven't had the chance to play with it thus yet...
I just wrote a python program that captures an image to a jpg file every 60 seconds, then reads the EXIF Brightness Value from the jpg file (logs it and another program plots it.)
(Not Javascript, but the concept is the same.)
EXIF Brightness Values:
Code is here: https://github.com/slowrunner/Carl/tree/master/Projects/LogLightValueAndPlot