{"id":13865965,"url":"https://github.com/bmengineer-gear/RuTiTe","last_synced_at":"2025-07-15T02:31:11.572Z","repository":{"id":55447215,"uuid":"268606960","full_name":"bmengineer-gear/RuTiTe","owner":"bmengineer-gear","description":"Python script to record flashlight runtime using a Raspberry Pi and a TSL2591","archived":false,"fork":false,"pushed_at":"2021-01-05T14:37:16.000Z","size":413,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-23T06:31:02.969Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmengineer-gear.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-01T18:57:24.000Z","updated_at":"2024-06-29T15:15:41.000Z","dependencies_parsed_at":"2022-08-15T00:30:49.006Z","dependency_job_id":null,"html_url":"https://github.com/bmengineer-gear/RuTiTe","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/bmengineer-gear/RuTiTe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmengineer-gear%2FRuTiTe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmengineer-gear%2FRuTiTe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmengineer-gear%2FRuTiTe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmengineer-gear%2FRuTiTe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmengineer-gear","download_url":"https://codeload.github.com/bmengineer-gear/RuTiTe/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmengineer-gear%2FRuTiTe/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265390848,"owners_count":23757604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-05T12:00:42.419Z","updated_at":"2025-07-15T02:31:11.229Z","avatar_url":"https://github.com/bmengineer-gear.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# RuTiTe\nPython script to record flashlight runtime test (RuTiTe) using a Raspberry Pi and a TSL2591.\n# Installation\nTo install this script, just copy rutite.py to the directory you're working in. You'll need to have python3 installed along with the following dependencies:\n- time\n- math\n- os\n- csv\n- board\n- busio\n- adafruit_tsl2591\n- RPi\n- argparse\n- sys\n- matplotlib\n\nRun the following commands to install all the required dependencies on a fresh install of Raspberry Pi OS:\n\n    pip3 install adafruit-blinka\n    pip3 install adafruit-circuitpython-tsl2591\n    pip3 install matplotlib\n\n# Usage\nAt it's most basic, you can just run `python3 rutite.py`, and this script will fire up. It will print out to the terminal to let you know when it's ready for you to turn on a light and start the test, and record the runtime to a .csv file.\n## Options\nIf you want to get fancy, there's plenty of configurability available.\n- `-i` sets the interval between recordings, so `python3 rutite.py -i 0.5` would record a measurement every half second, instead of the default once per second.\n- `-o` sets the output file name, so `python3 rutite.py -o flashlighttest.csv` would save the results in a file named flashlighttest.csv. If this isn't used, a timestamp will be used as the file name.\n- `-d` sets the maximum duration the test will run for in minutes. `python3 rutite.py -d 15` If this isn't specified, the test won't stop automatically after a certain time.\n- `-tp` sets the percent to terminate the test at. If you wanted the test to stop after the output reaches 10% of what it was at 30 seconds, you would run `python3 rutite.py -tp 10`. Note that when it reaches the set level, it keeps recording for a bit longer.\n- `-pp` and `pd` both determine how often updates are printed to the terminal. If you wanted an update every time the output had changed by 10%, or every 30 minutes (whichever came first), you would run `python3 rutite.py -pp 10 -pd 30`.\n- `-r` records relative time alongside the absolute time. If you're plotting the results afterwards, this makes sure the graph will start at 0 - but it will make the recorded file size a bit bigger.\n- `-g` outputs a plot when the script is done. Right now this only works when either `-d`, `-tp`, or both is used and you let the script run until it's done.\n## Example\nI ran the following test of the highest mode of a lumintop FW1A:\n```\npi@rpi0:~ $ python3 runtimetestandplot.py -o FW1Aturbo.csv -i 0.3 -d 5 -g 'FW1A Turbo' -pp 10\n```\nAs a result I got the following printed out in the terminal:\n```\n15:14:16 Saving as FW1Aturbo.csv\n15:14:18 Ready to start the test. Turn on the light now.\n```\nAt this point I turned on the light in the mode I wanted to test:\n```\n15:14:24 Light detected. Recording started.\n15:14:55 Sampling period complete. The output at 30s was 1931.6 lux. Sampling period max = 2159.3 lux, min = 1903.9 lux.\n\tThe test will run until you stop it, or it has recorded for 5 minutes, or it reaches 193.2 lux (10.0% of the output at 30s).\n15:15:13 Output is at 90% (1732 lux)\n15:15:17 Output is at 79% (1523 lux)\n15:15:27 Output is at 69% (1324 lux)\n15:15:36 Output is at 58% (1125 lux)\n15:16:10 Output is at 48% (930 lux)\n15:17:27 Output is at 38% (734 lux)\n15:19:24 Test complete\n```\nAll done! I now have two files in my directory - `FW1Aturbo.csv` and `FW1A Turbo.png`.\nThe csv file looks something like this:\n```\ntime,lux,absolute time,lumens\n1594408465.550655,2159.2926719999996,,2159.2926719999996\n1594408466.3578901,2142.548352,,2142.548352\n1594408467.1652982,2131.97952,,2131.97952\n...\n```\nand the image looks like this:\n![example plot](https://github.com/bmengineer-gear/RuTiTe/blob/state-machine/exampleplot.png)\n# Limitations\nMaximum lux of the sensor is 88,000. If the lux recorded by the sensor is too high, you should adjust your setup so less light is hitting the sensor.\n# Hardware Setup\nThis test uses a raspberry pi and the sensor. I've added LEDs to my setup for quick status indication at a glance, but these are completely optional. No screen is required if you're starting tests over ssh. An internet connection is required for timing.\n![wiring diagram](https://github.com/bmengineer-gear/runtimetest/blob/master/runtimetestwiringdiagram.png)\nI've replaced the first LED with a green one on my own setup.\n# Test Setup\nTo perform a test with the finished hardware, you'll need a setup that directs some of the light from a flashlight to the sensor. Even a room will work, but objects moving around (including you) can affect the results, as can anyone turning on a light. I use a box for this reason.\nIt's important that the light being tested is the only light source hitting the sensor, and that test setup remains stationary while the test is running.\n# Planned Changes\n- Add option to record IR mode for IR lights\n- Switch from sloppy delays to scheduling\n# Known Issues\n- If the light exceeds the sensor ceiling, the script will crash. If this happens, uncomment `#sensor.gain = adafruit_tsl2591.GAIN_LOW` in the code, and try again. If it still happens, you need to adjust your setup so less light reaches the sensor.\n- Plotting doesn't work if you manually stop the test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmengineer-gear%2FRuTiTe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmengineer-gear%2FRuTiTe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmengineer-gear%2FRuTiTe/lists"}