How to measure Lux value using Phototransistor circuit

Hi all,

i am doing lux meter using Photo-transistor(TEPT4400) with microchip controller. I got resistance value from ADC samples but I dont know how to convert resistance to lux. Please help me to find out.

This is my circuit
Analog i/p
| |
3.6 V ------/////----|----___/-----| |GND
10K /^/^ |
photo transistor (TEPT4400 )
Hole controller will be working on 3.6v Battery supply.

This is my adc(10bit) Code

START_ADC(ADC_CHANNEL_INTTEMP);
for(val=0;val<NUMSAMPLES; val++)
{

samples[val]= GET_ADC();

}
average = 0;
for(val=0; val<NUMSAMPLES; val++)
{
average += samples[val];
}
average /= NUMSAMPLES;

average = 1023 / average - 1;
average = SERIESRESISTOR / average; // Photo resistance value

is my formula in the code is correct?
what i have to do further to get lux value?
Anybody give me the formula

Thanks,
Pratheep

Do you have a Lux meter for verification? If so then make a graph that relates the two properties (resistance measured vs Lux meter reading taken at same time). Then it should be a simple scaling calculation. The Arduino lib actually has a built in function Map() you can use if you know the scaling parameters, however this will only work if your graph gives a straight line.

You might also want to consider whether converting from one set of arbitrary units to another equal arbitrary set is actually necessary in your application. It usually isn't, though it may still be handy to know how.

DonMilne:
Do you have a Lux meter for verification? If so then make a graph that relates the two properties (resistance measured vs Lux meter reading taken at same time). Then it should be a simple scaling calculation. The Arduino lib actually has a built in function Map() you can use if you know the scaling parameters, however this will only work if your graph gives a straight line.
...

For non linear curves I developed multiMap() - Arduino Playground - HomePage -

Hi,
Yes, i have lux meter. Ill try your method.
BTW , Can you verify my code ? can you confirm my resistance calculation is correct or not?.

Thanks,
pratheep

Hi Mr. JohnLincoln,
I cant swap the positions because the hardware is already designed for temperature sensor but now we need to use that the same hardware for Lux meter because we don't want to go for schematic change. So please give me more ways to get correct output using the same circuit.

Thanks,

John's suggestion was a "nice to have" - you already had answers before that that easily produce a working design. There's no magic solution here, i.e. there's no getting around the need to calibrate the range of results.

And ps... while I'm here. While I didn't demur at the time for politeness sake, in fact I didn't really agree with John's suggestion anyway. If you do that graph I mentioned earlier, IMHO is isn't important if the slope of the line is positive or negative. It makes no difference at all to the calculation or the result.

Hi DonMilne,
the problem is below 1000lux the resistance of my lux sensor is not stable and there is huge variations in resistance readings. So i am having doubt on my resistance measurement. So kindly tell me my resistance measurement formula is correct or not. i am using the same for temperature measurement and it is working fine.

thanks,

Hi,

i think my resistance measurement is correct. i need to measure range from 0 to 10000 lux.

Thanks,

You are using a phototransistor, which doesn't have a "resistance".

You can calculate the equivalent resistance of the photodiode at a given light level, but that doesn't help to get the lux value.

What you should do is convert the ADC reading into a lux value. The only way to do that is to compare ADC readings obtained to light levels measured using an accurate lux meter, and work out the proper conversion table or function.

I would need to see a complete function before I could declare it right or wrong. I particularly need to know the types of all variables and 'defines' used. Also I would need to know what function (mapping) you're trying to perform, in generic math terms.

If you're simply trying to correct for instability by averaging a large number (N) of samples, and you have freedom over the choice of N, then the calculation is easier if N is a power of 2. Then, given the sum of N ADC readings, the rounded integer average is given by a simple shift :-

average = (sum + (N>>1)) >> Y;

where Y=Log2(N) => 2^Y == N. E.g. if N=1024, Y=10.

I have to say, if the instability is that bad then I'd want to investigate why. E.g. you may just need a capacitor on a reference voltage. I can't think of any good reason for an LDR reading to fluctuate that much, assuming that air drafts etc aren't affecting it.

Hi DonMilne,
following is my code and i am using photo transistor.

#define THERMISTORNOMINAL 10000

#define NUMSAMPLES 10

// the value of the 'other' resistor
#define SERIESRESISTOR 10000

int samples[NUMSAMPLES];

u8 ADC_GetTemp(u16 adc);
void ADC_Task(void);
static void delay_ms(u8 ms);

void ADC_Task(void)
{
u8 v, val, cur_temp;
u16 temp;
s8 adj_temp, t;
u16 ad_value;
u16 TempBattPercnt;//ver-00.0.9
float average;

ADC_POWER_ENABLE();

ad_value = 0;
START_ADC(ADC_CHANNEL_INTTEMP);
for(val=0;val<NUMSAMPLES; val++)
{
samples[val]= GET_ADC();
}
average = 0;
for(val=0; val<NUMSAMPLES; val++)
{
average += samples[val];
}
average /= NUMSAMPLES;

average = 1023 / average - 1;
average = SERIESRESISTOR / average;

}

Hi michinyon,

You are correct i am using photo transistor and it does not have resistance, then how do i measure the lux value. can you give formula?

thanks,

You've been told by several forum members what you have to do, and you chose to ignore the advice. So why bother posting a question?

Hi jre,

Now i am making table for actual Lux value and voltage read from adc for voltage to lux conversion. But at the same time i am looking for easy way to covert my adc readings to lux.

Thanks,

You can put a list of pairs in Excel and let it derive a formula for it

  • you must make an xy graph and enable "show formula" (something like that)

I'll make a graph.

Thank you

i am doing lux meter using Photo-transistor(TEPT4400) with microchip controller. I got resistance value from ADC samples but I dont know how to convert resistance to lux.

You are simply using the wrong sensor.
I use the LLS05 for my homebrew light meter, but these are no longer easily found. The replacement is made by Sharp and can be found at farnell/Newark:
http://www.newark.com/sharp/ga1a2s100ly/optical-light-detector/dp/14N9297

These devices have an internal Op-Amp and a filter with a linear output that matches the perceived brightness of the human eye; hence LUX.