TKLamp Live Logger
01 What it does
The TKLamp TK2303D tester sends its lumen reading over USB about four times a second while it is on. This free Python script opens a window on your computer that shows that reading live, records a run on the computer's clock, keeps a history of your runs, and uploads them to your Runtime list on hCRI.io. If you prefer, the same script runs in the terminal.
- Live reading and chart with a scale that stays put as the run grows, plus a line of time and lumens every second that you can turn off.
- Start and Stop a run, or stop it automatically after a number of minutes.
- Exact start and end times from the computer's clock, and the dark start trimmed off.
- Run limits: start when the light reaches a level, stop when it falls below a level, stop after a set time, and stop automatically when the tester has sent no readings for 5 minutes (changeable). The values are remembered.
- Calibrate the counts-per-lumen scale with a lamp of known output.
- History of every run with its chart, rename, upload to hCRI.io, share link, stop sharing and delete.
- Live station: while you are signed in, the reading goes to a link you can open on any phone or computer (
hcri.io/?live=...), also when no run is recording. See Live station. - Updates itself: the script checks for a newer version when it starts.
- Sign in from the window to create the hCRI.io token for you, the same way Companion's Settings does.
Why use it instead of Transfer Data?
The tester's own Transfer Data sends the stored readings after the test, with no date or time, so the real start and end of the run are unknown. Because this script records while the test is running, the start time, end time and length are exact. You choose the name, and it can upload and make a share link for you.
No install? Use it in your browser
Open the browser version in Chrome or Edge on a Mac, Windows or Linux computer. It uses Chrome's built-in USB serial access, so there is nothing to install (the Windows CH340 driver is still needed if the tester does not show up). It has the same live chart, calibrate, history, rename, upload and share, and uses your hCRI.io website sign-in. It does not run the Python script: it is a JavaScript version of the same logic. Runs are kept in that browser, so download or upload them to keep them. When you are signed in and Live station is on, it also sends the live reading to your live link (see Live station), with a box to type what you are testing. Safari, Firefox and phones cannot do this.
Prefer your phone?
hCRI Companion does the same with the ESP32 bridge, no computer needed. See Using a TKLamp tester and the manual.
02 Install
- Install Python 3From python.org if you do not have it. Use the python.org installer, because it includes the window toolkit (tkinter). On Windows, tick "Add Python to PATH". See Mac, Windows and Linux for the other Pythons.
- Install the serial libraryOpen Terminal (Mac) or Command Prompt (Windows) and run
pip install pyserial. - Download the scripttklamp_live.py. Save it in a folder you will find again, such as Documents.
- Plug in the testerConnect the tester's USB cable to the computer and switch the tester on. It must be on and sending readings. The computer sees it as a CH340 USB serial device, which may need a driver (see Mac, Windows and Linux).
- Run itIn the folder where you saved it, run
python tklamp_live.py(on a Mac you may needpython3). The window opens. Use--clifor the terminal version.
The script checks for a newer version each time it starts and replaces itself when there is one (it keeps the old copy as tklamp_live.py.bak). Use --no-update to turn that off.
No tester to hand? python tklamp_live.py --simulate makes a made-up fading light so you can try everything.
03 Connect to hCRI.io (optional)
To upload from the script it needs an API token, the same kind hCRI Companion uses. The script can create one for you.
- In the windowClick Sign in... at the top right, enter your hCRI.io email or username and password, and click Sign in. The script creates a token named "TKLamp logger (your computer)" and remembers it in a file in your home folder (
.hcri_tklamp.json), readable only by you. The top right then shows hCRI.io: your name with a Sign out button, which forgets the token on this computer. - Or let it askIf you tick Upload when saving a run and are not signed in, it opens the sign-in box first, then uploads.
- In the terminalRun
python tklamp_live.py --login. The password is not shown. - Or paste a tokenMake one on hCRI.io (account settings, API tokens, Create token) and run
python tklamp_live.py --token YOUR_TOKEN --save-token, or set theHCRI_TOKENenvironment variable.
Your password is sent only to hCRI.io, once, and is never saved or printed. You can delete the token from your account settings at any time.
Keep the token private
Anyone with the token can add curves to your account. Do not paste it into a chat, a screenshot or a shared file.
04 The window
The Live tab is where you record. Top row: pick the tester and click Connect (it is chosen for you when it is found; Refresh looks again). The big number is the live lumens.
| Control | What it does |
|---|---|
| Start run / Stop run | Starts recording from the computer's clock, then stops it. When you stop, a box shows the length, readings, first and last lumens and the exact start and end times, and asks for a name (see below). |
| The chart | Lumens against time. The vertical scale starts at zero and only grows, so the line does not jump about. Before you start it shows the live reading; while recording it shows the run. |
| Chart width | 30 seconds, 2 minutes or 10 minutes (the chart scrolls with the run), or Whole run to fit everything on screen. |
| Clear | Clears the live chart (not available while recording). |
| Stop after | Minutes after which the run stops by itself. Blank means you stop it. |
| Run limits | Four boxes, all remembered between runs (blank = off): Start at (Start run waits until the light reaches this many lumens, and the button says Cancel while it waits), Stop below (ends the run when the output stays below this level for 3 seconds, only after it has been above it), Stop after (minutes) and No readings for (minutes, default 5: ends the run when the tester has been silent that long, and the run ends at the last reading). A run that stops by itself is saved at once under its suggested name, with a note saying why, and you rename or upload it from History. |
| Start at the first reading | Drops the dark readings before the light came on, so the run starts at its first lit reading with no jump from 0 (on by default). |
| Choose where the run starts | After you stop a run, the red start line on its chart can be dragged to any point (the app: tap Choose where the run starts; the web logger: in the Save dialog, or Trim start... in History). It pulses so you can see it can be grabbed, and a label shows the seconds and lumens while you drag. Everything before the line is left out of the saved and uploaded run. Use default puts it back where the two options above put it. |
| Start at the peak | Drops everything before the highest reading, so the run starts at the peak (off by default; turning it on turns off Start at the first reading). |
| Show readings | Shows a line of clock time, elapsed time and lumens every second under the chart, with REC marking the recorded ones. Untick it to hide the list; the setting is remembered. In the terminal the same line is turned off with --no-readout. |
| Calibrate... | Put a lamp of known output in the sphere, enter its lumens and click Measure. It averages 8 seconds and shows the new counts-per-lumen scale; Save scale keeps it. See Calibrating the scale. |
| Live station | Turns your Live station on or off (the same switch as on the website and in the app). The label shows Live: on or Live: off after you click it. |
| Live note... | Type what you are testing and some details (for example “Olight Warrior 3, turbo, fresh cell”). They show on your live page and can be changed during a run. |
| Sign in / Sign out | Creates or forgets the hCRI.io token (see above). |
Saving a run. When you stop, give it a name (suggested: TKLamp run 2026-10-27 18:00) and choose whether to upload it to Runtime on hCRI.io and whether to make a share link. Click Save. Discard throws the run away. A .partial.csv copy is written every couple of seconds while recording, so a crash does not lose the run. Keep the computer awake and the cable in for the whole run; for a 24 hour run turn off sleep first. If the cable comes out mid-run, the run so far is kept and you can still Stop and save it. You cannot close the window while a run is recording.
Live station: watch from anywhere
Switch it on or off from any of these (it is one switch on your hCRI.io account): the website (Explore → Runtime → Live station), the Companion app (Settings → Live station), the web logger (the Live station box, tick Share live), or this script (the Live station button in the window, or --live on / --live off in the terminal). While the script is signed in to your hCRI.io account, it sends the reading to your personal link every 5 seconds. The link shows Live with the current lumens when no run is recording, and Live run at the top while one is. Anyone with the link can watch; the web logger can be started, stopped and cleared from the website or the app's Live view. the same screen is in the app under Settings → Live station (the eye button). Runs also trigger emails when they finish, have a problem, go silent or fall below a limit you set; a plain live reading never does. A simulated run is sent as “Simulated: ...”.
Type what you are testing with Live note... (window) or --live-title / --live-details (terminal). Chat and social sites show a snapshot of that name and the lumens when they fetched the link; only the page itself is live.
05 History: view, rename, upload, share
Every saved run appears on the History tab, newest first, with its name, start time, length, first and last lumens and whether it is on hCRI.io. Click a run to see its details and chart (start and end times, points, percentage of output left, the scale used).
| Button | What it does |
|---|---|
| View | Opens the run's chart and details in a larger window (double-clicking a run does the same). |
| Rename... | Changes the name and the saved files. If the run is on hCRI.io it asks whether to rename it there too (re-uploaded under the new name, and the old copy deleted; an old share link stops working). |
| Upload | Sends the run to your Runtime list on hCRI.io (Explore, then Runtime). The same name replaces an earlier run. |
| Share link | Makes a link anyone can open without signing in, and copies it. It uploads the run first if needed. Pressing it again shows and copies the same link. |
| Stop sharing | Turns the link off; the old link stops working. |
| Open on hCRI.io | Opens the share link if the run has one, otherwise hCRI.io. |
| Delete | Deletes the run from this computer, and asks whether to delete it from hCRI.io too. |
| Open folder | Opens the folder where the runs are saved (TKLamp runs in your home folder, or the folder you gave with --output-dir). |
If an upload fails, the run is still saved here; try Upload again later. A run saved with the terminal version in the same folder shows up here too.
06 Terminal mode
Run python tklamp_live.py --cli. The script also uses the terminal by itself when this Python has no tkinter or there is no screen.
- Start the scriptIt finds the tester's port by itself (or asks you to pick one; you can also give
--port COM5or--port /dev/cu.usbserial-1420). The live lumens appear on one line. - Press Enter to startIf you gave
--start-atit waits until the light reaches that level and then starts by itself (Enter cancels the wait). The line showsRECwith the elapsed time and the number of readings, and a line of clock time, elapsed time and lumens is printed every second. Add--no-readoutto turn those lines off and keep only the one updating line. - Press Enter again to stopOr use
--duration 30to stop after 30 minutes. Ctrl+C also stops and keeps what was recorded. - Name, upload, shareIt shows the summary with the exact start and end times, asks for a name, offers to upload (signing in first if needed) and offers a share link. If the upload fails, the run is already saved:
python tklamp_live.py --upload TKLamp_2026-10-27-18.00.00.jsonsends it later.
07 Calibrating the scale
The tester sends a raw sensor count, and the script divides it by counts per lumen to show lumens. The default, 313.2, was measured on one calibrated tester using its 2150 lm calibration lamp. Each tester, and each recalibration, can differ a little.
To set it for yours, put a lamp of known output in the sphere and wait for it to settle. In the window click Calibrate..., enter the lamp's lumens and click Measure, then Save scale. In the terminal run python tklamp_live.py --calibrate 2150 (use the lamp's lumens). It reads for 8 seconds, shows the new scale and saves it for later runs. This is the same as Set scale in hCRI Companion. Calibrate again if you recalibrate the tester.
08 All options
| Option | What it does |
|---|---|
--cli | Use the terminal instead of the window. |
--no-readout | Do not print (or show) the time and lumens line each second. |
--port PORT | Serial port, if it is not found automatically. |
--calibrate LUMENS | Set and save the scale from a lamp of known output (terminal). |
--scale N | Use this counts-per-lumen for this run only. |
--start-at LM | Wait until the light reaches this many lumens, then start recording. |
--stop-below LM | Stop when the output stays below this many lumens for 3 seconds (only after it has been above it). |
--duration MIN | Stop by itself after this many minutes. |
--idle-timeout MIN | Stop when no reading has arrived for this many minutes (default 5; 0 = off). |
--save-settings | Remember the four limits above for next time. The window remembers them by itself. |
--no-trim | Keep the dark readings before the light came on. |
--trim-peak | Start the run at its peak instead of its first lit reading. |
--output-dir DIR | Where to save runs. Default: the current folder in the terminal, TKLamp runs in your home folder in the window. |
--login | Sign in with your hCRI.io email/username and password, create a token and remember it. |
--token T, --save-token | Use an API token you made on the website, and remember it. |
--site URL | Another hCRI.io address (default https://hcri.io). |
--live on|off | Turn your Live station on or off, then carry on. |
--live-title TEXT, --live-details TEXT | What you are testing, shown on your live page (see Live station). An empty title clears it. |
--no-update | Do not check for a newer version of the script at start-up. |
--upload FILE.json | Upload a run saved earlier, then exit. |
--simulate | No tester needed: a made-up fading light, to try the script. |
09 The files it saves
TKLamp_<date>.json: the run (name, spacing, lumens) plus its start and end times, length, number of readings, the scale used, and whether it was uploaded or shared.TKLamp_<date>.csv: minutes in the first column and the lumens in the second, ready for Upload CSV on the Runtime page.~/.hcri_tklamp.json: your settings (scale, token, run limits, whether to show the readings). Readable only by you.
Runs are stored at one point per second (wider spacing beyond about 27 hours, hCRI.io's 100,000 point limit). hCRI.io does not store the start and end times yet, so they stay in the saved .json.
10 Mac, Windows and Linux
The window needs tkinter with Tk 8.6 or newer. The script checks this when it starts and tells you if it is old or missing; without tkinter it falls back to the terminal.
| System | Notes |
|---|---|
| Mac | Use Python from python.org: it includes a current Tk. Homebrew Python needs brew install python-tk. Apple's own python3 (from the Xcode tools) has an old Tk 8.5 that can look wrong or draw badly, especially in dark mode, and the script warns you. The tester appears as /dev/cu.usbserial-… or /dev/cu.wchusbserial…. Recent macOS has the CH340 driver built in; on an older Mac install the CH340 driver from wch-ic.com. |
| Windows | Use the python.org installer, tick "Add Python to PATH" and keep "tcl/tk and IDLE" ticked. If the tester does not show up (Device Manager, then Ports should list a USB-SERIAL CH340 as COM5 or similar), install the free CH340 driver (CH341SER) and plug it in again. If pip is not recognised, use py -m pip install pyserial and run the script with py tklamp_live.py. |
| Linux | Install python3-tk for the window. Add yourself to the dialout group (sudo usermod -aG dialout $USER, then log out and in) to open the port. |
11 Troubleshooting
| Symptom | Try |
|---|---|
| The window does not open, the terminal is used | This Python has no tkinter, or there is no screen. Install Python from python.org (Mac, Windows) or python3-tk (Linux). |
| "Old Tk" warning | This Python's Tk is older than 8.6. Install Python from python.org and run the script with that one. |
| No tester listed, or "No tester found" | Check the cable is a data cable and the tester is plugged in and on. Install the CH340 driver on Windows or an older Mac, and see the notes above. Then click Refresh. |
| The number shows "--" | No readings are coming in. Switch the tester on and leave it sending; check you picked the right port. |
| "No module named serial" or "needs pyserial" | Run pip install pyserial (or python -m pip install pyserial, or py -m pip ... on Windows). |
| Permission denied on Linux | Add yourself to the dialout group, then log out and in. |
| The number differs from the tester's screen | Calibrate with a lamp of known output. |
| "certificate verify failed" (Mac) | Python from python.org has no root certificates until you run its certificate step. The script now falls back to the Mac's own certificates by itself; if it still fails, open the Python folder in Applications and double-click Install Certificates.command, then try again. |
| "Sign-in failed: Invalid credentials" | Check the email or username and password. You can also make a token on the website and use --token. |
| "hCRI.io said 401" | The token is wrong or was deleted. Click Sign out, then Sign in again (or run --login). |
| The upload says the account limit is reached | Delete some runtime curves on hCRI.io, then click Upload again. |
Using the tester's own Transfer Data instead? The manual and the Runtime page's Upload CSV explain how to set the seconds between readings for that file.