4

I've been looking for a way to retrofit light sensors to my laptops which lack one.

The best specification I've found so far is in the ACPI 3b spec, section 9.2, that details how such a sensor would be implemented. I assume Linux would also follow the spec.

My first question: is there such a device on the market? A small USB dongle that measures light and provides that to the OS. I already have a Spyder i1 that can do this, but it's overkill and large.

Second question: would it be possible to implement this using Arduino and V-USB? If yes, how would one approach the project?

Is it even possible to do this via USB?

Background: a small USB microcontroller and an LED can function decently as a light sensor by measuring LED capacitance, with no other external parts. This is well documented and also tested by myself.

brainwash
  • 690
  • 5
  • 19

1 Answers1

5

if you have a microcontroller with a USB stack already you can use a photoresistor, photodiode and convert the voltage, resistance,current to a digital signal with the ADC of the uC, see http://www.electronics-tutorials.ws/io/io_4.html there are also ICs available (search for 'ambient light sensor ic') if you don not wnat ot use the ADC there are ICs that can be connected to I2C bus etc

normally sensors are implement USB HID class, see http://www.sensorwiki.org/doku.php/tutorials/building_a_usb_sensor_interface

the linux kernel module (driver) for ambient light sensors is acpi-als.ko or in case of a usb (HID) light sensor hid-sensor-als.ko

http://lxr.free-electrons.com/source/drivers/iio/light/hid-sensor-als.c

( https://github.com/torvalds/linux/blob/master/Documentation/hid/hid-sensor.txt, https://lwn/net/Articles/348576/ ) if you build an own device you have to make it compliant to this driver

there are ready solutions for this (http://www.hughski.com/colorhugals , http://www.yoctopuce.com/EN/products/usb-environmental-sensors/yocto-light-v3 ) but they are really expensive

the windows driver is sensor-hid-class-driver ( https://msdn.microsoft.com/de-de/windows/hardware/drivers/hid/sensor-hid-class-driver).

(https://www.chalk-elec.com/?p=2144 control LCD backlight over HID USB)

ralf htp
  • 9,149
  • 4
  • 22
  • 34
  • 1
    The ColorHug hint is the most useful as the blog post points to a readable firmware code that does exactly that. Also found something a bit closer to my intended implementation: https://github.com/edy555/avr-hidtemp and http://vusb.wikidot.com/project:hid-sensor-example-compatible-with-windows8-8-1-10-b – brainwash Feb 13 '17 at 09:35