A simple USB light detector consisting of a simple circuit based on an ATtiny44 and a LED. Readings are accomplished by running a userspace tool on the host. Each run will return the most recent measurement.
Measured values will be within 0…4294967295 (32 bit value), with 0 meaning "pretty bright" and higher values meaning "less light".
Value | Environment |
---|---|
8…15 | average desk lamp |
30.000…60.000 | clouded sky |
> 800.000 | sensor hidden in a drawer |
Run make
within the avr
directory. Make sure to the the fuses to "External
Crystal" and disable CLKDIV8 (see avr/fuses
for the values I used).
The sample client is a single file. You'll need
libusb to compile it.
Usually, you can just install the devel package (apt-get install libusb-dev
)
on Debian-like distributions.
To compile the client, just run:
gcc -o lichtsensor client/lichtsensor.c -lusb
Just run the lichtsensor
binary after connecting the sensor:
% ./lichtsensor
18214
If you get a Operation not permitted, try running it as root and take a look at the libusb FAQ.
The sensor's readings are likely to drift over time as there is no compensation or calibration yet.