The TSL235 is a light-to-frequency converter.

This library reads TSL235 output frequency and convert it to irradiance, and then to illuminance.

Irradiance is the power of electromagnetic radiation per unit area (radiative flux) incident on a surface. It's expressed in

*watt per square metre*, the symbol is

*Ee*.

In photometry, illuminance is the total luminous flux incident on a surface, per unit area. It is a measure of how much the incident light illuminates the surface, wavelength-weighted by the luminosity function to correlate with human brightness perception. It's expressed in

*lux*, the symbol is

*Ev*.

Irradiance and illuminance are related by the luminosity function. The luminosity function describes the average spectral sensitivity of human visual perception of brightness. This function it is standardized, usually the CIE 1924 function it is used for conversion.

The standard luminosity function is normalized to a peak value of unity at 555 nm, so the value of the constant in front of the integral is usually rounded off to 683 lm/W.

*Vlambda* is the luminosity function.

To measure TSL235 output we count the number of risign edge on the clock external input pin of Atmega.

Using this frequency count method, we can measure up to F_CPU / 2. Given a 8Mhz micro frequency, we can measure up to 4Mhz.

References of the below summary goes to

Irradiance Meter by Jonathan Thomson.

TSL235 returns a frequency dependant on spectral irrandiance or the light source.

Every photon that crash on the photodiode area is beeing absorbed and converted to current depending on his wavelength. Current is then trasformed to frequency by a Current-to-Frequancy converter.

The photodiode has a spectral responsivity that vary upon wavelength. The responsivity over a specify wavelength is specify by datasheet. TSL235 photodiode react from 300 to 1100nm.

We can say that

given

*fO* as the output frequency,

*Re(lambda)* as responsivity over wavelength,

* Ee(lambda)* source light spectral irradiance over wavelength

If we fix a normalized spectral irradiance of a know source as

*X(lambda)*, the frequency output from sensor is:

Because

*fX* is computed starting by the normalized spectral irradiance

*X(lambda)*, and our light source has the same shape of spectral irradiance, we can relate

*fX* and

*fO* by a constant

*k*.

So, the spectral irradiance of the measured source is [uW/(cm^2)/nm]

and the irradiance of the source [uW/(cm^2)]

The measured illuminance [lm/m^2] of the source is related to irradiance by the formula:

Note that we have to transoform Ee from uW/(cm^2)/nm to W/(m^2)/nm, this is the reson for the 10.000 (1/cm^2 to 1/m^2) and 1.000.000 parameter (uW to W).

Now, beacuse we are want to use micro to do all the computation, if we fix the lumisonisity function, the sensor responsivity, and the source spectral function we can evaluate a fixed constant that we can use in lower resource environment, like micro, to calculate the illuminance.

so

and

Some matlab helpers are provided with code to:

- grab responsivity function from a the datasheet graph (using ginput)
- export luminosity function on a desired wavelength interval
- export a normalized spectral irradiance for the light source
- test the function above

Setup parameters are stored in file tsl235.h

**Code**
**Notes**
- read risk disclaimer
- excuse my bad english