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

Add autolux #29

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add autolux #29

wants to merge 2 commits into from

Conversation

mareuter
Copy link

This is an implementation of #20 using the contributions from there as well as a couple of ideas from the C++ library. Please make sure the other contributors get credit for this as I just did the "last mile" part. I also corrected a couple of doc strings that were referencing a different library.

@mschlenstedt
Copy link

mschlenstedt commented Aug 9, 2024

Thanks for implementing this feature! I looked at the code and the datasheet "Designing the VEML7700 Into an Application" (https://www.vishay.com/docs/84323/designingveml7700.pdf) just to understand what you have done here.

I think there might be two mistakes in the code:

  1. issue:

According to the datasheet the correction formula should be used for lux > 1000 (page 5 "For illuminations > 1000 lx a correction formula needs to be applied.". But you use the formular when Ambient Light Level > 100. Should here the lux value pre-calculated and then checked for "if lux > 1000"?

  1. issue:

The used formular in line 246 is wrong in my opinion:

((6.0135e-13 * lux - 9.3924e-9) * lux + 8.1488e-5) * lux + 1.0023 ) * lux

The power values are missing and the brackets are wrongly set. The original furmula from the datahseet (page 5):

Correcting the lux value with the help of the correction formula yields:
a x (1500 lux)^4 + b x (1500 lux)^3 + c x (1500 lux)^2 + d x (1500 lux) = 1658 lux
With the polynomial coefficients:
a = 6.0135-13
b = -9.3924-9
c = 8.1488-5
d = 1.0023

This is in python:

(6.0135e-13 * lux ** 4) + (-9.3924e-9 * lux ** 3) + (8.1488e-5 * lux ** 2) + (1.0023 * lux)

If you test the correct formular with 1500 lx, you get 1658 lx.

@mareuter
Copy link
Author

For Issue 1

So, it's unclear from the flow chart on page 21 which is where the code derives the flow from where that 1000 lux limit on page 5 comes into play. It's not mentioned there. Not sure what to do about that. Any suggestions?

For Issue 2

If I run the formula as is through python, I get your answer:

lux = 1500
(((6.0135e-13 * lux - 9.3924e-9) * lux + 8.1488e-5) * lux + 1.0023 ) * lux
1658.1429843

The code formatting makes it look a bit weird by moving the opening parentheses to the line above.

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

Successfully merging this pull request may close these issues.

2 participants