Closed colindgrant closed 4 years ago
hmm -- I will take a look at it... 65523 does look like a strange value
PR #15 submitted @colindgrant - thank you for reporting this. It was clearly a typo.
@jerryneedell ok, great! Thanks for the quick response.
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: https://github.com/adafruit/Adafruit_CircuitPython_SHT31D/blob/10c0a43b796d9fc8e521e9a8fe8bc6927163e970/adafruit_sht31d.py#L220
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:
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.