Using Claude-Light
Claude-Light has an RGB LED and an
AS7341 spectral sensor.
You choose the LED levels, from 0 (off) to 1 (full brightness), and the
sensor reports ten numbers: the light at 415, 445, 480, 515, 555, 590, 630
and 680 nm, plus clear (total visible) and nir
(near-infrared). The readings are counts from 0 to 65535. The sensor also
sees the room light, which changes during the day.
The Green Machine
The Green Machine has one input (the green LED level) and one output (the 515nm reading). It is a good place to learn about reproducibility, statistics, linear regression, optimization and design of experiments.
- How reproducible is a particular setting? Run the same experiment many times, make a histogram of the results, and compute the mean and standard deviation. Does the distribution look Gaussian?
- How does your measurement change during the day? Measure the background with G=0 and subtract it from your data.
- How does the output depend on the input? Measure at several green levels, plot the output against the input, and fit a line.
- Find the input setting that gives an output of 25000.
The RGB machine
The RGB machine has three inputs and ten outputs. The version on the instrument also shows a photo of the LED during the measurement.
- Repeat a measurement many times and compare the mean and standard deviation of each channel.
- Vary one input and plot how each output depends on it.
- Use multivariate linear regression to model the outputs from the inputs.
- Find the inputs that give 25000 on the 480nm, 515nm and 630nm channels at the same time.
The API
For scripts and notebooks, request
https://claude-light.cheme.cmu.edu/api?R=0.12&G=0.45&B=1
Missing inputs are 0, and values outside 0 to 1 are clipped. The reply is JSON with the inputs and the ten outputs:
{"in": [0.12, 0.45, 1.0],
"out": {"415nm": 1869, "445nm": 30238, "480nm": 14230, "515nm": 29596,
"555nm": 6576, "590nm": 4703, "630nm": 6662, "680nm": 2247,
"clear": 58911, "nir": 1559}}
In Python:
import requests
def measure(R=0, G=0, B=0):
resp = requests.get('https://claude-light.cheme.cmu.edu/api',
params={'R': R, 'G': G, 'B': B})
resp.raise_for_status()
return resp.json()['out']
measure(G=0.5)['515nm']
The claude-light-python package wraps this for Jupyter notebooks and handles retries for you.
For spreadsheets, https://claude-light.cheme.cmu.edu/csv?G=0.5
returns just the 515nm reading as text, so in Google Sheets
=IMPORTDATA("https://claude-light.cheme.cmu.edu/csv?G=0.5")
puts a measurement in a cell.
When the instrument is busy
There is one instrument for everyone, and each measurement takes about
0.7 s, so it can do about 1.5 measurements per second in total. Requests
wait their turn in a queue. If the queue is full you get HTTP 503, and if
you already have several measurements waiting you get HTTP 429. Both come
with a Retry-After header saying how many seconds to wait.
Please measure one point at a time rather than sending many requests at
once; it is not faster, and it makes everyone wait.
import time, requests
def measure(R=0, G=0, B=0):
while True:
resp = requests.get('https://claude-light.cheme.cmu.edu/api',
params={'R': R, 'G': G, 'B': B})
if resp.status_code in (429, 503):
time.sleep(int(resp.headers.get('Retry-After', 3)))
continue
resp.raise_for_status()
return resp.json()['out']
Other endpoints
/status: whether the instrument is busy and how many measurements are queued./stats/data.json: the usage statistics behind the statistics page.- /docs: interactive API documentation.
Using Claude-Light with an AI agent
The repository includes agent skills, instructions that teach AI coding agents (Claude Code, Codex, VS Code with Copilot, Cursor, Gemini CLI, OpenCode) how to use Claude-Light well: measuring one point at a time, waiting when the instrument is busy, subtracting background, and choosing good designs. Install one into your project with knowhow (you need uv) or npx skills:
uvx --from git+https://github.com/jkitchin/knowhow knowhow add jkitchin/claude-light --skill claude-light # or, with Node.js npx skills add jkitchin/claude-light --skill claude-light
Add -g to install it for all your projects. Then ask your agent
things like "measure the 515nm response at 11 green levels and fit a line" or "find
R, G and B that give 25000 on the 480, 515 and 630nm channels". Use
knowhow upgrade later to get updates.
A second skill, claude-light-server, is for people who run their
own Claude-Light instrument. The
skills folder
has both.
More exercises
The exercise list goes further: detection limits, interpolation, uncertainty quantification, machine learning with scikit-learn and xgboost, active learning and Bayesian optimization, design of experiments, background subtraction, and automating data collection.
Data and privacy
Every measurement is recorded, so the data can be used for the statistics page and for teaching. IP addresses are not stored. Each one is looked up in an offline database to get an approximate location (the city), and replaced by a one-way hash so unique users can be counted. Location data is from DB-IP (CC BY 4.0).
About
Claude-Light is inspired by the work of Sterling Baird and Taylor Sparks, What is a minimal working example for a self-driving laboratory? (Matter, 2022) and Building a "Hello World" for self-driving labs (STAR Protocols, 2023). It runs on a Raspberry Pi 4 with a web API instead of MQTT, a wired network connection, and a camera. The README has the history of the project, the parts list and the setup instructions.