{"id":22213148,"url":"https://github.com/leivosepp/lesson-lightsensor-tsl2591","last_synced_at":"2026-05-08T14:02:09.365Z","repository":{"id":132646841,"uuid":"80075469","full_name":"LeivoSepp/Lesson-LightSensor-TSL2591","owner":"LeivoSepp","description":"Raspberry PI and using Adafruit light sensor TSL2591 in Windows 10 IoT Core.","archived":false,"fork":false,"pushed_at":"2018-09-19T09:24:01.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-28T07:52:20.118Z","etag":null,"topics":["adafruit","digital-sensors","i2c-sensors","light","light-sensor","lux","raspberry-pi","sensor","tsl2591","uwp","windows-10"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LeivoSepp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-26T01:22:26.000Z","updated_at":"2024-03-02T01:54:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd968bb3-a0a0-4dad-a76a-c2d32daab3c3","html_url":"https://github.com/LeivoSepp/Lesson-LightSensor-TSL2591","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LeivoSepp/Lesson-LightSensor-TSL2591","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeivoSepp%2FLesson-LightSensor-TSL2591","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeivoSepp%2FLesson-LightSensor-TSL2591/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeivoSepp%2FLesson-LightSensor-TSL2591/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeivoSepp%2FLesson-LightSensor-TSL2591/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LeivoSepp","download_url":"https://codeload.github.com/LeivoSepp/Lesson-LightSensor-TSL2591/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeivoSepp%2FLesson-LightSensor-TSL2591/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32783452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adafruit","digital-sensors","i2c-sensors","light","light-sensor","lux","raspberry-pi","sensor","tsl2591","uwp","windows-10"],"created_at":"2024-12-02T21:08:44.333Z","updated_at":"2026-05-08T14:02:09.305Z","avatar_url":"https://github.com/LeivoSepp.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Adafruit Light Sensor TSL2591\nThis project is an example on how to use the Adafruit light sensor TSL2591 in Raspberry PI and Windows 10 IoT Core.\n\n## What is this sensor?\nhttps://www.adafruit.com/products/1980\n\n![image](https://cloud.githubusercontent.com/assets/13704023/22854428/2092a836-f077-11e6-9ec5-2808ea62d6fc.png)\n\nThe TSL2591 luminosity sensor is an advanced digital light sensor, ideal for use in a wide range of light situations. \nThis sensor is very precise, allowing for exact lux calculations and can be configured for different gain/timing ranges \nto detect light ranges from 188 uLux up to 88,000 Lux on the fly.\n\n## How to connect this sensor into Raspberry PI?\nTo connect this sensor to Raspberry PI you need 4 wires. Two of the wires used for voltage Vin (+3V from Raspberry) and ground GND and remaining two are used for data. \nAs this is digital sensor, it uses I2C protocol to communicate with the Raspberry. For I2C we need two wires, Data (SDA) and Clock (SCL).\nConnect sensor SDA and SCL pins accordingly to Raspberry SDA and SCL pins. \n\n![image](https://cloud.githubusercontent.com/assets/13704023/22856381/011e2ce2-f099-11e6-8025-732774f7c35a.png)\n\n## How do I write the code?\nI made it very simple for you. You just need to add NuGet package RobootikaCOM.TSL2591 to your project and you are almost done :)\n\nRight-click in your project name and then \"Manage NuGet packages\"\n![image](https://cloud.githubusercontent.com/assets/13704023/22802711/964f83d6-ef1a-11e6-9e7e-398257c2eda0.png)\n\nOpen \"Browse\" tab, write \"robootika\" in search-window and then install RobootikaCOM.TSL2591 package into your project.\n![image](https://cloud.githubusercontent.com/assets/13704023/22802827/0ba11ed8-ef1b-11e6-8f46-64a8bf8fd432.png)\n\nAfter adding this NuGet package, you just need to write 3 lines of code.\n\n1. Add reference to this module\n````C#\nusing RobootikaCOM.TSL2591;\n````\n\n\n2. Create an object for sensor: \n````C#\n        private TSL2591 TSL2591Sensor = new TSL2591();\n````\n\n3. Write a while-loop, to read data from the sensor in every 1 sec.\n````C#\n            while (true)\n            {\n                double currentLux = TSL2591Sensor.GetLux();\n                Task.Delay(1000).Wait();\n            }\n````\n\nFinal code looks like this. \nIf you run it, you do not see anything, because it just reads the data, but it doesnt show it anywhere.\nYou need to integrate this project with my other example, where I teach how to send this data into Azure.\n\n````C#\nusing Windows.ApplicationModel.Background;\nusing System.Threading.Tasks;\nusing RobootikaCOM.TSL2591;\n\nnamespace LessonLightSensorTSL2591\n{\n    public sealed class StartupTask : IBackgroundTask\n    {\n        private TSL2591 TSL2591Sensor = new TSL2591();\n\n        public void Run(IBackgroundTaskInstance taskInstance)\n        {\n            while (true)\n            {\n                double currentLux = TSL2591Sensor.GetLux();\n                Task.Delay(1000).Wait();\n            }\n        }\n    }\n}\n````\n\n## Advanced sensor tuning: timing and gain\nThis sensor support five different timing and three gain options. \n\n* **Timing**: this means how many samples the sensor will take before calculating the light level.\nChanging the integration time gives you a longer time over which to sense light. Longer timelines are slower, but are good in very low light situtations!\nThis sensor has three parameters for timing. \n   * 100ms the shortest measure time, use in bright light\n   * 200ms average measure time, use in medium light (default)\n   * 300ms average measure time, use in medium light\n   * 400ms long measure time, use in dim light\n   * 500ms long measure time, use in dim light\n````C#\n        TSL2591.INT_TIME_100MS;\n        TSL2591.INT_TIME_200MS;\n        TSL2591.INT_TIME_300MS;\n        TSL2591.INT_TIME_400MS;\n        TSL2591.INT_TIME_500MS;\n````\n* **Gain**: You can change the gain on the fly, to adapt to brighter/dimmer light situations. \n   * TSL2591.GAIN_LOW: use in bright light\n   * TSL2591.GAIN_MED: use in average light (default)\n   * TSL2591.GAIN_HIGH: use in very dim light\n   * TSL2591.GAIN_MAX: use in darkness\n\nTu use timing and gain, you need to write one additional line of code. First parameter for method **SetTiming** is gain and second parameter is timing. \nFor example, setting gain MAX and timing maximum (500ms), you can measure almost complete darkness.\n````C#\n        public void Run(IBackgroundTaskInstance taskInstance)\n        {\n            TSL2591Sensor.SetGain(TSL2591.GAIN_HIGH, TSL2591.INT_TIME_500MS);\n            while (true)\n            {\n                double currentLux = TSL2591Sensor.GetLux();\n                Task.Delay(1000).Wait();\n            }\n        }\n````\n## Can I change I2C address?\nI2C address is used to communicate with the sensor. Many sensors have I2C address hardcoded, and this sensor exactly this.\n**You cannot change I2C address, it is fixed to 0x29**\n\n## Sensor technical Details\n\n* Extremely wide dynamic range 600,000,000:1\n* Lux Range: 188 uLux sensitivity, up to 88,000 Lux input measurements.\n* Temperature range: -30 to 80 *C\n* Voltage range: 3.3-5V into onboard regulator\n* Interface: I2C\n* This board/chip uses I2C 7-bit address 0x29 (fixed)\n\n\n## Indoor and outdoor lighting conditions\n\nIlluminance | Example\n--- | --- \n0.002 lux | Moonless clear night sky\n0.2 lux | Design minimum for emergency lighting (AS2293).\n0.27 - 1 lux | Full moon on a clear night\n3.4 lux | Dark limit of civil twilight under a clear sky\n50 lux | Family living room\n80 lux | Hallway/toilet\n100 lux | Very dark overcast day\n300 - 500 lux | Sunrise or sunset on a clear day. Well-lit office area.\n1,000 lux | Overcast day; typical TV studio lighting\n10,000 - 25,000 lux | Full daylight (not direct sun)\n32,000 - 130,000 lux | Direct sunlight\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleivosepp%2Flesson-lightsensor-tsl2591","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleivosepp%2Flesson-lightsensor-tsl2591","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleivosepp%2Flesson-lightsensor-tsl2591/lists"}