The tiny light sensor board gives some nice and stable analog readings based on amount of ambient light. It gives a "0" well ahead of full darkness however.
Software-wise I treat it almost identical to temperature sensor - read values into a circular buffer and calculate "standard deviation" of past readings, then compare that to the most recent reading.
It responds quickly to light changes so I can use past readings to generate a dynamic threshold - too high of a change in light value either high up OR down triggers the Peril-sensing part of the code.
It needed only a little extra tweaking - the math for generating dynamic thresholds, etc doesn't work well at very low values so if the readings are already very low (e.g. ADC reading is less than about 10) I just substitute some known static thresholds instead.
I think I'll try to mount this sensor inside the glasses frame.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.