TSL235R

RaresPlescan edited this page Nov 7, 2013 · 14 revisions
Clone this wiki locally

logo

TSL235R sensor is a light intensity sensor or an irradiance to frequency converter.

Ratings :

Supply voltage : 2.7 V to 5.5 V

Output : digital, 50% duty cycle

Measuring values : 0.001 uW/cm2 - 1000 uW/cm2

Producer's page and documentation :

Product page

PDF

Source code: TSL235R code source for Daisy Pi

The source code exaplained :

It relies on the WiringPi library to read a GPIO pin ( GPIO18 or pin 12 of the main header ).

The absolute values are 1.000.000 times apart each other ( absolute darkness and maximum light ) and are given as counts per second. Since a normal day indoor reading would give tens or hundreds of thousands of hertz and dark or night reading would give less than 100 hertz, an autoscale mechanism was implemented.

Thus, it takes first some readings ( 3 batches by default, parameter customisable ) and determines the average number of readings to be expected for 300 milliseconds. Then, another batch of readings are made, for the specific number discovered previously. This is also customisable and in the end, the offered parameter will be in fact a mathematical mean of the more exact last reading.

This is done to provide accurate readings despite small temporarily light variations or missed pin readout. Also, as no standard number of counts per second would be average, auto scale is mandatory in the beginning to avoid blocking the program in "forever reading" ( if a typical 36.000 hertz value would be expected during a night reading, the full reading would could take up to 36.000 seconds - 10 hours ).

The code is subject to improvement of course. Any way of reading the pin would do and be usable in this code - for now we use WiringPi as it seems nice and fast ( we needed megahertz grade software readings to be performed ).