Skip to content

Humidity calculation does not match formula given in datasheet #14

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

Closed
colindgrant opened this issue Mar 9, 2020 · 3 comments · Fixed by #15
Closed

Humidity calculation does not match formula given in datasheet #14

colindgrant opened this issue Mar 9, 2020 · 3 comments · Fixed by #15
Assignees

Comments

@colindgrant
Copy link

I suspect a bug in the conversion from raw sensor data into relative humidity.
I would appreciate one of the maintainers reviewing this issue to determine if it is in fact a bug.

The conversion in question is here:

humidity[i] = 100 * (word[(i*2)+1] / 65523)

Note division by 65523. Based upon my review of datasheets and other libraries, I believe this value should in fact be 65535 (i.e., 2^16 -1)

Here are two versions of the Sensirion datasheet:
Sensirion currently links to this one (rev. February 2019)
Adafruit's tutorial links to this one (rev. May 2015)

Both give the following formulas in section 4.13 Conversion of Signal Output:
image

Note the divisor is 65535 (i.e., 2^16 -1). Further, it appears that the Arduino equivalent library uses that value:
https://github.com/adafruit/Adafruit_SHT31/blob/c735e72e027caa230ca126bd0b49569b9c5b81ea/Adafruit_SHT31.cpp#L146

As a final reference point, the formula given in the datasheet for the HTU21D-F is nearly identical, and again the Adafruit Arduino library appears to use it verbatim:
https://github.com/adafruit/Adafruit_HTU21DF_Library/blob/4c90679095303e19938997ba5c624f846c9e2205/Adafruit_HTU21DF.cpp#L137

Being fairly new to Python and microcontrollers I could very well be missing something. If that is the case, I would humbly suggest a comment in the code to explain why 65523 was chosen, in order to inform other users like myself, and avoid taking up more of your attention on this question.

Thank you for your review and for an excellent library!
It will soon be at work helping to grow crops and save water in California.

@jerryneedell
Copy link
Contributor

hmm -- I will take a look at it... 65523 does look like a strange value

@jerryneedell
Copy link
Contributor

PR #15 submitted
@colindgrant - thank you for reporting this. It was clearly a typo.

@colindgrant
Copy link
Author

@jerryneedell ok, great! Thanks for the quick response.

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 a pull request may close this issue.

2 participants