Fast sampling with I2C device BH1750

Hi! Breaking my head with one concept...

I have to measure light flickering index with Arduino. In first place, I thought about LDR to measure tiny changes in voltage given by it to calculate this index. It didn't go well so I decided to change my sensor to a light sensor, measuring luxes [lx]. I chose BH1750

So general idea is to SAMPLE LUX VALUES EVERY 21ms. Here is why: Expected flickering is around 100Hz (2x50Hz -> double of the amount of Hertzs in current flow in my country) - it corresponds to period of 20ms. So finally I decided to use "undersampling" to catch it and that's why the period of sampling is exactly 21ms.
I tried to use different modes, different sensivities, different time registers... but no luck.

The changes that I measure are definietly too small. The flickering index calculated from collected data is around 1.5% while it should be at least 30% in the source I have tested...

So... the questions are:

-> is this idea of measuring even correct?
-> can I use this lux sensor? I mean...it can't be TOO SLOW...In most hardcore mode it samples data every 16ms...
-> maybe I2C devices are not good for those purposes and I should go for analog output sensor and use old good built-in ADC?

Any help would be nice, thank You in advance!

#include <Wire.h>
#include <BH1750FVI.h>

BH1750FVI LightSensor;

void setup()
{
Serial.begin(115200);
LightSensor.Begin(Addr_LOW, Continous_L);
LightSensor.SetMTReg(69);
LightSensor.SetSensitivity(2.00);
}

void loop()
{
float lux = LightSensor.GetLux();// Get Lux value
Serial.println(lux);
delay(21);
}

Based on this article, I think your concept for your code is not right.

Percent Flicker = 100% x (max - min)/(max + min)

Flicker index = Area above Mean / Total Area

from the picture you can see that first thing is you need to define your cycle (probably will need to monitor the AC line to determine start and end of 1 cycle)

Then I would suggest to sample the lux levels as fast as you can and at the end of your cycle get the min and max values to determine the "percent flicker"

Hope that helps.

I am unclear on why you expect this to work.

The conversions are giving you an average of the light level during the sampling period. Undersampling only works when you can get an instantaneous value - for example if you are sampling an analog signal with an ADC with sample and hold. When you're using a digital sensor that has already averaged the signal over a period of time that doesn't meet the nyquist criteria, you're never going to be able to get the signal you want.

Use a faster light sensor.

Be aware that analog light sensors also usually have a non-zero response time.

Thank you for your help. Well, now I understand why it coudn't work...
I found a great sensor -> APDS-9002 <- and I will use ADC to sample those values.

Topic to close