I want to mesure the lux in some environment using a LM393, i’m using the analog pin so the values that i get into the cayenne are between 0 and 1023, but this values aren’t coming in lux, if the environment are too dark it would go to values near 1023 and if it is too bright it would be near the 0 values. There’s any way to mesure in lux?
The LM393 is just a comparator that you may be using in an amplifier circuit with a light sensing device. We will need more specifics on your setup. What Arduino are you using, etc.
What you could do is get an external light meter and calibrate your output values over a range of brightnesses then do a linear interpolation.
For example, if you measure on your light meter in the office that you are at 500 lux, and 800 on your analog pin, then turn the light off and measure say 100 lux and 200 on your analog pin, assuming a linear relationship over that range, you could use this formula:
lux = 100 + (ADC - 200) * (500-100) / (800-200)
lux = 100 + (ADC - 200) * 0.667
eg. For an ADC reading of 500, lux would be 300.
Now if you don’t have access to a proper light meter, there are phone apps available to approximate.