adafruit / Adafruit_BME280_Library

Arduino Library for BME280 sensors
Other
336 stars 305 forks source link

Parsing H4/H5 humidity calibration data #44

Closed AmedeeBulle closed 4 years ago

AmedeeBulle commented 5 years ago

According to the datasheet, dig_H4 and dig_H5 are signed integers on 12 bits

The following code handles these as pure 16bits signed, which will never be negative... https://github.com/adafruit/Adafruit_BME280_Library/blob/07c30892653baceda6a426a8f8f79cc22194c590/Adafruit_BME280.cpp#L454-L455

The datasheet is ambiguous as it refers to these 12 bits values as signed short, but the BoschSensortec reference code definitely handles the values as 12 bits signed integer -- the (int8_t)cast on the msb ensures the sign is propagated