The two upper bits get lost in the raw ADC reading of the sensor.
Function Adafruit_CCS811::readData() in the file Adafruit_CCS811.cpp:103, released version 1.0.4.
What was meant, is to take the lowest 2 bits of the buf[6], shift left and or with the value buf[7]. But what is written, is to take buf[6], shift left, take the lowest two bits (that are zero) and then or with the buf[7].
A bug
The two upper bits get lost in the raw ADC reading of the sensor. Function
Adafruit_CCS811::readData()
in the file Adafruit_CCS811.cpp:103, released version 1.0.4._rawADCreading = (((uint16_t)buf[6] << 8) & 3) | ((uint16_t)buf[7]);
Correct solution
_rawADCreading = ((uint16_t)(buf[6] & 3) << 8) | ((uint16_t)buf[7]);
Explanation
What was meant, is to take the lowest 2 bits of the
buf[6]
, shift left andor
with the valuebuf[7]
. But what is written, is to takebuf[6]
, shift left, take the lowest two bits (that are zero) and thenor
with thebuf[7]
.