Skip to content

Potential sign problem with the calibration values for humidity #19

Closed
@robert-hh

Description

@robert-hh

In line 197 of the driver, the calibration constants are unpacked with

        coeff = list(struct.unpack('<hBBBBb', bytes(coeff)))

This goes into humidity_calib[3] and humidity_calib[4], which in the Bosch data sheet are told as signed quantities. Unpacking like above results in decoding them as unsigned quantities. So this line should be:

        coeff = list(struct.unpack('<hBbBbb', bytes(coeff)))

From the data sheet:

0xE4 / 0xE5[3:0] dig_H4 [11:4] / [3:0] signed short
0xE5[7:4] / 0xE6 dig_H5 [3:0] / [11:4] signed short

I have no device where the sign bit is set, so I can only simulate the behavior.

Note: I came along these lines when considering to carry over the very elegant conversion of similar data from the BME680 driver. There, the sign is considered.

Metadata

Metadata

Assignees

No one assigned

    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