duncanportelli
duncanportelli

Reputation: 3229

Light Sensor collecting inaccurate data

I am collecting data from the light sensor for a certain amount of time:

mSensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_FASTEST);

The problem is that the values collected are not always accurate and frequent. By "not accurate", I mean that if I start the sensor at a certain time, the first reading sometimes will be an old one of long before I began collecting data.

Also, since the delay is declared as SensorManager.SENSOR_DELAY_FASTEST, I get a lot of values and sometime I get 100s of records in one second and sometime I do not even get one reading in three seconds.

Can someone explain what this issue might be and if there are any solutions please?

Upvotes: 1

Views: 224

Answers (2)

M.KD
M.KD

Reputation: 81

It is probably the sensor property. I believe it contains an internal buffer FIFO which explains why you are getting the first reading as an old reading that you have already done. This internal buffer functions in saving a limited number of scans or readings waiting for the user to pull them out. Try reset the sensor's FIFO if you can before reading each time.

Upvotes: 0

moeburn
moeburn

Reputation: 26

i believe it is because these light sensors only send data when there is a change in light. So you will not get any readings if the light level does not change, but if you wave your hand in front of it or turn a dimmer switch up slowly, you will get 100s of readings.

Upvotes: 1

Related Questions