Closed AmedeeBulle closed 4 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
signed short
(int8_t)
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