Grove Light Sensor - conversion to lux

grovepi
lightsensor

#1

Hello,
I am reading from the analog light sensor, and I get values between 500 and 700 or so.
But, what are these values? How do I convert these to lumen or lux?
Thanks!


#2

Hi @LuCavallin,

That’s a really good question.


I’ve read more on this sensor and I found out that the light sensor's model is GL5528.
Its datasheet can be found here:

So, by going over the datasheet, you may find some interesting bits of information. Especially on page 2.

What you need from this datasheet is a plot between the light sensor’s resistance and the amount of lux - take a look in the datasheet.
After you get the graph, we then need to interpret it in order to get a formula - this thing can take a lot of time.

Unfortunately, the datasheet doesn’t seem to be really informative - it’s quite hard to decipher it.

You may want to take a look on this forum - these guys are also struggling with this sensor in particular and their solution may be worth something:


Then, I’ve looked over the Grove Light Sensor's schematics and I saw the following:

Let’s say we find out a correlation between the lux and the output voltage of the light sensor.
But there’s another impediment we have: it’s the amplifier we have there. We’re not sure what are the amplifier's settings.
Again, we would need to calculate (physics involved too) in order to reach a correlation between the lux and the Grove Light Sensor's output voltage. And this thing can be prone to human errors as-well.

Anyway, here’s the amplifier's datasheet:

The good thing about this datasheet (which comes from TI) is that it’s a lot more explicative.


Personally, I think you have 2 alternatives which sound a lot better:

  1. Use a professional light sensor in order to calibrate this Grove Light Sensor. For each reading, you would find out the ratio between the lux and the analogRead value from the GrovePi.
    The bad thing about this method is that you need to take lots of measurements (tens of them) in order to get a somewhat precise sensor - that’s because the sensor’s resistance isn’t proportional to the amount of lux.

  2. Use another Light Sensor that’s made for measuring the lux - it needs to have a Grove connector. We currently don’t have another sensor in our catalog that suits this need, but Seeed has one.
    The following sensor is compatible with our GrovePi platform.
    Here’s a link to it: https://www.seeedstudio.com/Grove-Luminance-Sensor-p-1941.html


Please let me know what decision you further want to take and if there’re any more questions, Luca, please bring them on to me.

Thank you!


#3

Hi I have the same problem, I just need an easy formula to convert the sensor value i obtain using the code given here [https://github.com/DexterInd/GrovePi/tree/master/Software/NodeJS]

(https://github.com/DexterInd/GrovePi/tree/master/Software/NodeJS)

I have tried these two formulas given in the link you mentioned in your comment but its not giving correct values, I am comparing the values to a lx values i obtain through my android phone. If you have an easy way to convert sensor value to lux , lumens or kandela please let us know.

  1. L = 350 * R-1.43
  2. L = 63 * R-0.7

My code is given below

var GrovePi = require('node-grovepi').GrovePi;
var Commands = GrovePi.commands;
var Board = GrovePi.board;
var UltrasonicDigitalSensor = GrovePi.sensors.UltrasonicDigital;
var AirQualityAnalogSensor = GrovePi.sensors.AirQualityAnalog;
var DHTDigitalSensor = GrovePi.sensors.DHTDigital;
var LightAnalogSensor = GrovePi.sensors.LightAnalog;
var DigitalButtonSensor = GrovePi.sensors.DigitalButton;
var led = new GrovePi.sensors.DigitalOutput(3);
function LightReading() {
    console.log('starting Light Sensor LM358');

    var board = new Board({
        debug: true,
        onError: function (err) {
            console.log('Something wrong just happened');
            console.log(err);
        },
        onInit: function (res) {
            if (res) {
                console.log('GrovePi Version :: ' + board.version());
                var lightSensor = new LightAnalogSensor(2);
                /*var sensor_value = Math.log(res);
                var lux = Math.exp((res)/80.0);*/
                console.log('Light Analog Sensor (start watch)');
                lightSensor.on('change', function (res) {
                    console.log(' Resistance value = ' + res);
                    var sensor_value = Math.pow(res, -0.71) * (62.77);
                    var lux = Math.pow(res, -1.43) * (350);
                    var sensor_value2 = Math.pow((res / 1000), -0.71) * (62.77);
                    console.log('Sensor value in Lumern = ' + sensor_value + ' Resistance value = ' + res + ' Lux value = ' + lux);
                    console.log('Sensor value 2' + sensor_value2);

                })
                lightSensor.watch(1000);
            }
        }
    })
    board.init();
}

#4

Hi @rameez.saleem,

Read the above quote from my previous reply. If reading the sensor doesn’t provide you with an accurate reading compared to that of your smartphone and if those fellows’ algorithm is not good enough, then you can try creating a map of resistance-by-lux values.

Also, when copying code on forums you can use the ``` code ``` format to format the code nicely.

Thank you!


#5

Hi thanks for the answer I read up on the sensor and its datasheet and have used my cell phones reading to calibrate this sensor thought its not ideal but for the prototype it works, One thing i can not figure out is what is the maximum threshold value this sensor can measure, I get a resistance value of ~3.2 in a brightly lit room which becomes around 500-700 lux based on my calibration but it does not go below this value even if i shine direct sun light on it. This makes me think the maximum threshold for measurement is quite low may be max 1000 lux since sunlight is around 50k - 100k lux. I have read the datasheet but cannot figure out what is the maximum threshold value it can measure.


#6

Hi @rameez.saleem,

This sensor is particularly cheap, so it is expected not to be a professional sensor.

If making the room brighter doesn’t have any effect on the sensor’s resistance, then it’s pretty normal to assume that it hit its limit, even though it’s quite low.


I have an idea, though I’m not sure if it’s going to work in your case. Maybe you can use a filter glass (shaded) that reduces the amount of light that hits the sensor. You’d get lower readings and for that you’d need to calibrate the sensor accordingly.

But since adding a shade to the sensor only moves the range higher, you can come up with another trick: have multiple sensors with different levels of shaded glass that would cover for a much larger range.
Thus, you can use that to detect the different levels of brightness outdoor and indoor with sufficient accuracy.

I find this idea to be quite effective and cheap.


Let me know if it works for you.

Thank you!