Using the Adafruit TSL2591 Digital Light Sensor and a Raspberry Pi to monitor daily sunlight conditions.
The TSL2591 is a high dynamic range digital light sensor.
It can detect infrared, full-spectrum and human-visible light, then transmit that data over a serial connection.
By collecting this data, we are able to:
- Calculate the lux value for the current light conditions.
- Report real-time data for monitoring or automation.
- Save historical data to give insight on changes over time.
- Provide a dashboard to control the sensor and visualize data.
- Most importantly, determine if your location is: ☁️ shade, partial shade, partial sun, or full sun ☀️
![image](https://private-user-images.githubusercontent.com/7357311/312263355-0e67d4a5-35bb-48b4-93cf-d556c9c5a480.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3MDI3NDEsIm5iZiI6MTcyNTcwMjQ0MSwicGF0aCI6Ii83MzU3MzExLzMxMjI2MzM1NS0wZTY3ZDRhNS0zNWJiLTQ4YjQtOTNjZi1kNTU2YzljNWE0ODAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDkwNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA5MDdUMDk0NzIxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Y2YzZjlkODNmOTI1NTA3MWM4NDM5ODE0YTZkZjUxZDRjOGNhYWEzNDkyZDE0OWJkNGI4Y2JiNDBiZWFhY2Y4ZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.O8ExQUY8iFOn3VoKdN7sHhoSUxbCgvTtUwrT-CUvOTM)
The TSL2591 sensor is connected to a Raspberry Pi via i2c.
Connecting the sensor to the Pi:
- Vin to 3.3V
- GND to GND
- SDA to SDA
- SCL to SCL
"Sunlight Meter" automatically adjusts sensor gain and integration time.
This helps ensure accurate readings and avoid saturation in high light conditions.
"Sunlight Meter" runs an API that allows remote access to the sensor data and jobs.
Connect remotely to:
- Start/Stop any recording job.
- Receive real-time readings and light conditions.
- Download historical data as a SQLite DB.
- Check device wifi-signal strength.
The "Sunlight Dashboard" is a web app that displays the current light conditions and historical data.
- Visualize historical light conditions
- Control the sensor
- Export the results
From https://en.wikipedia.org/wiki/Lux:
Illuminance (lux) | Surfaces illuminated by |
---|---|
0.0001 | Moonless, overcast night sky (starlight) |
0.002 | Moonless clear night sky with airglow |
0.05–0.3 | Full moon on a clear night |
3.4 | Dark limit of civil twilight under a clear sky |
20–50 | Public areas with dark surroundings |
50 | Family living room lights |
80 | Office building hallway/toilet lighting |
100 | Very dark overcast day |
150 | Train station platforms |
320–500 | Office lighting |
400 | Sunrise or sunset on a clear day |
1000 | Overcast day; typical TV studio lighting |
10,000–25,000 | Full daylight (not direct sun) |
32,000–100,000 | Direct sunlight |
- Frontend: HTML, TailwindCSS, HTMX, JS
- Backend: Go
- Hardware: TSL2591, Raspberry Pi Zero W