Skip to content

Humidity calculation does not match formula given in datasheet #14

Closed
@colindgrant

Description

@colindgrant

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions