This library (with examples) is designed to be integrated in projects using any kind of photocell to retrieve the light intensity (in Lux or footcandles). It handles the GL55xx photocell series but any other photocell can be configured too.
-
Download latest release
-
On your Arduino IDE, click "Sketch" menu and then "Include Library > Add .ZIP Libraries"
-
You can now use the library for your project or launch an example ("File > Examples")
You'll need a resistor in addition of the sensor in order to create a "voltage bridge". The needed voltage can be either 5V or 3.3V.
Here is an example for the GL5528 photocell:
One example is provided with this library:
If your photocell is in the GL55x series, you just have to initialize the photocell class with the right element:
Photocell | Init value |
---|---|
GL5516 | LightDependentResistor::GL5516 |
GL5528 | LightDependentResistor::GL5528 |
GL5537-1 | LightDependentResistor::GL5537_1 |
GL5537-2 | LightDependentResistor::GL5537_2 |
GL5539 | LightDependentResistor::GL5539 |
GL5549 | LightDependentResistor::GL5549 |
In order to use an other photocell, you'll have to provide the library a curve of this kind: I[lux]=constant_1/(R[Ω]^constant_2).
Most of the time, the curves are logarithmic curves which mean you'll have to transform and solve equations. A full explanation on how to do it step by step is shown in the header file. You'll also find how GL55xx equations were solved in the Excel sheet.
This project is under MIT license. This means you can use it as you want (just don't delete the library header).
If you want to add more examples or improve the library, just create a pull request with proper commit message and right wrapping.
- Thank you leonheuler for your contribution helping me improve the ADC bits resolution handling in the library.
- Thank you miccgn for your contribution adding (optional) linear smoothing in the library.