I have an AMBI light sensor from Liquidware all set up and working. It provides input on an analog pin as opposed to a pulse like on the more popular TAOS sensor. However, it is also logarithmic. My question is, how would I go about converting the value from this sensor to something more useful, such as lux? If it was linear I could use a map command because I know the range of it, but I don think that’ll work in this case. Any help is appreciated.
The Sharp sensor used http://sharp-world.com/products/device/ … 01wp_e.pdf already has a logarithmic amp built-in, so Iout=log(light intensity). It should be linear already. But it has a tiny current output 5 to 50uA and not sure if the AMBI resistor R1 is the best idea, you need an op-amp to get full 0-5V output from it. So I’m suspicious of the AMBI.
There’s not much you can do if you have an 8-bit A/D converter range 0-255dec and a sensor that can detect from 3-55,000lux which is almost a 16 bit dynamic range. That’s why the pulse output light sensors are better, using 16-bit timers to read them.
You could try a look up table or some kind of linearization of the sensor.
Are you sure that lux is more useful to you than log(lux)? For most of the applications I’d have for this sensor, I’d be very happy with a logarithmic encoding. What arithmetic do you need to do with the value?
If you really want to convert log to linear, I’d suggest computing the exponential function rather than burning memory space on a lookup table. At least in Atmel-land, you get the standard C/C++ exp() function as part of avr-libc.