-->
Page 1 of 1

Problems with CCS811 sensor (or i2cwrite)

PostPosted: Fri Mar 20, 2020 6:06 am
by Warthog
Hello,
I have a breakout board with a ccs811 and SI7021 temp/hum sensor. I wanted to write the temp und humidity data into the ENV_DATA register of the ccs81, but when I read the data again, it seems that writing the data into the register was not successful.

Output of my debug lines:

Code: Select allccs811 CO2 :2985
ccs811 TVOC:393
ccs811 CO2 :4798
ccs811 TVOC:670
Humidity: 31.250  Temperature: 27.249 <-- (from SI7021)
ENV_DATA before: hum=17 0   temp=0 0 <-- reading the ENV_DATA register
 bytes written 4 <-- looks good
write to ENV_DATA: hum=62  temp=52 <-- hum must be leftshifted, temp=temp+25
ENV_DATA  after: hum=17 0   temp=0 0 [b]<-- *** PROBLEM ***[/b]
BMP280 Temp=27.28  QFE=1027.978 
ccs811 CO2 :3173
ccs811 TVOC:422
ccs811 CO2 :4973
ccs811 TVOC:696


Every minute I call this function via timer:

Code: Select allfunction read_SI7021()

   hum, temp, hum_dec, temp_dec = si7021.read()

   print(string.format("Humidity: %d.%02d  Temperature: %d.%02d", hum, hum_dec, temp, temp_dec))   
   
    css811_writeEnvData(hum, temp)  <-- writing to css811
   
end


Please see the attached file.

Re: Problems with CCS811 sensor (or i2cwrite)

PostPosted: Fri Mar 20, 2020 6:42 am
by AcmeUK
Do you have pullups on your I2C lines?
See here https://learn.sparkfun.com/tutorials/i2c/i2c-at-the-hardware-level

Re: Problems with CCS811 sensor (or i2cwrite)

PostPosted: Fri Mar 20, 2020 6:53 am
by Warthog
Yes, and I can read other registers without problems. The module itself is working.
Maybe there is a problem with writing more than one byte to the i2c bus?

Re: Problems with CCS811 sensor (or i2cwrite)

PostPosted: Fri Mar 20, 2020 9:12 am
by Warthog
After some more investigation, I found you that the ENV_DATA register is write-only.
So there is no way to check what number are currently used for calculation.

Thanks for support, this topic can be closed.