Close

Light Sensor Evaluation (Success)

A project log for Peril-Sensitive Sunglasses

A version of the Peril-Sensitive Sunglasses (as described by Douglas Adams in The Hitchhiker's Guide to the Galaxy)

minimum-effective-doseMinimum Effective Dose 04/13/2014 at 08:430 Comments

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