Photocell (Light Dependent Resistor) Library for Arduino
What is it?
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.
How to install
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")
How to connect a photocell to your Arduino
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:
Show light intensity every second with GL5528 photocell (in lux and footcandles)
How to use this library
With GL55xx photocells
If your photocell is in the GL55x series, you just have to initialize the photocell class with the right element:
With any other photocell
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.