Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gain scaling #2

Closed
cmsavage opened this issue Jan 18, 2018 · 4 comments
Closed

Gain scaling #2

cmsavage opened this issue Jan 18, 2018 · 4 comments

Comments

@cmsavage
Copy link

After reading light levels from multiple APDS-9301 boards using this library, I have found that the values returned by APDS9301::readLuxLevel() are at least an order of magnitude lower than expected and as measured from a phone app (though such measurements are not expected to be terribly accurate). Still, I found this library differs from how the TSL2561 library treats the empirical formula for lux found in the APDS-9301 data sheet. This library assumes that formula applies to the low gain readings, while the latter assumes it applies to the high gain readings (see here); the data sheet itself is ambiguous as to the gain to be used in that formula.

The end result is that the two libraries give lux values different by a factor of 16. Given my comparison with other sensors, I suspect the scaling in this library is incorrect. A fix would be to replace:

  if (getGain() == HIGH_GAIN)
  {
    ch0 /= 16;
    ch1 /= 16;
  }

with:

  if (getGain() == LOW_GAIN) 
  {
    ch0 *= 16;
    ch1 *= 16;
  }

Can anyone confirm a scaling issue and, if so, apply the fix?

@cmsavage
Copy link
Author

I got my hands on a lux meter and the APDS-9301 gives results accurate within 10-20% if the readLuxLevel() value is multiplied by 16. This library does seem to be applying the empirical formula at the wrong gain.

@mhord
Copy link
Contributor

mhord commented Jan 24, 2018

Please give it a try now. I've updated the library with the change you suggested.

@cmsavage
Copy link
Author

cmsavage commented Feb 2, 2018

The lux values are now consistent with a lux meter. Thanks!

@mhord
Copy link
Contributor

mhord commented Feb 2, 2018

Thanks for the feedback! We appreciate it!

@mhord mhord closed this as completed Feb 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants