CCS811 temperature and humidity calculation

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
redstorm
 
Posts: 2
Joined: Sat Sep 25, 2021 9:42 pm

CCS811 temperature and humidity calculation

Post by redstorm »

I 100% agree with the examples

i.e 25C = (25 +25)*512 equals 6400 uint16

howerver the formula in the function is adding a 0.5f as well, this isnt on the spec sheet for the CCS811 and like wise for the humidity calc a 0.5f is added.

I think the formulas should be:

Code: Select all

uint16_t hum_conv = humidity * 512.0f;
uint16_t temp_conv = (temperature + 25.0f) * 512.0f;
What am i missing, where is the 0.5 comming from? also in practice im seeing C02 drop as temp goes up and vice versa and susspect the temperature humidity environment is not being set correctly as per the spec sheet.



Code: Select all

/**************************************************************************/
/*!
    @brief  set the humidity and temperature compensation for the sensor.
    @param humidity the humidity data as a percentage. For 55.5% humidity, pass
   in 55.5
    @param temperature the temperature in degrees C as a decimal number.
   For 25.5 degrees C, pass in 25.5
*/
/**************************************************************************/
void Adafruit_CCS811::setEnvironmentalData(float humidity, float temperature) {
  /* Humidity is stored as an unsigned 16 bits in 1/512%RH. The
  default value is 50% = 0x64, 0x00. As an example 48.5%
  humidity would be 0x61, 0x00.*/

  /* Temperature is stored as an unsigned 16 bits integer in 1/512
  degrees; there is an offset: 0 maps to -25°C. The default value is
  25°C = 0x64, 0x00. As an example 23.5% temperature would be
  0x61, 0x00.
  The internal algorithm uses these values (or default values if
  not set by the application) to compensate for changes in
  relative humidity and ambient temperature.*/

  uint16_t hum_conv = humidity * 512.0f + 0.5f;
  uint16_t temp_conv = (temperature + 25.0f) * 512.0f + 0.5f;

  uint8_t buf[] = {
      (uint8_t)((hum_conv >> 8) & 0xFF), (uint8_t)(hum_conv & 0xFF),
      (uint8_t)((temp_conv >> 8) & 0xFF), (uint8_t)(temp_conv & 0xFF)};

  this->write(CCS811_ENV_DATA, buf, 4);
}

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: CCS811 temperature and humidity calculation

Post by mikeysklar »

It appears the 0.5f adjustment came from switching the from double to float for ENV_DATA.

https://github.com/adafruit/Adafruit_CCS811/pull/24

Have you done the necessary full burn in and incremental warm ups before measuring humidity and CO2?

User avatar
redstorm
 
Posts: 2
Joined: Sat Sep 25, 2021 9:42 pm

Re: CCS811 temperature and humidity calculation

Post by redstorm »

Thanks, after reviewing the code I confirmed the same as in pull request 24.

The sensor is started without a baseline set, allow it to warm up for 20-30 minutes (sensor is over a month old so should be well burnt in) and read the calculated baseline value from the sensor.
Then update the application and set the baseline and restart the the sensor,

The sensor is currently in a sealed plastic bin with a DTH22 for temperature and humidty

Code: Select all

This application note describes the baseline “save and restore” implementation supported in the
CCS811 application firmware. The baseline “save and restore” feature enables the sensors to indicate
the air quality of the ambient conditions as soon as possible from powering on the sensor regardless
of those conditions. The feature needs to be implemented using a particular sequence and timing to
be effective.
https://www.sciosense.com/wp-content/up ... CCS811.pdf

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”