Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:30 17 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CCS811 CO2 I2C sensor - CMM2

Author Message
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 425
Posted: 05:26pm 14 Feb 2021
Copy link to clipboard 
Print this post

Hi all

I have a ccs811 from Keystudio (https://wiki.keyestudio.com/KS0457_keyestudio_CCS811_Carbon_Dioxide_Air_Quality_Sensor   I can set up the sensor via Arduino using the libraries that ship with the device - and after burn in get sensible values.

For CMM2 I need to access the I2C directly -- and it's fair to say that I literally have no idea where to start
Assuming that I have SDA/SCL/VCC/Ground and that I've grounded "Wake" -- wired correctly -- and that the default address is: 0x5A  -- where do I start with figuring this out?

The "best" datasheet I can find on the CCS811 is here - https://cdn.sparkfun.com/datasheets/BreakoutBoards/CCS811_Programming_Guide.pdf

Any help / pointers greatly received ...

(Fingers crossed someone has already got one running ;-) )

Nim
Entropy is not what it used to be
 
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 425
Posted: 05:34pm 14 Feb 2021
Copy link to clipboard 
Print this post

This was posted on the Annex Basic forum:

######################################################################
CCS811_READ:
' Bit 3 = Data Ready 0:no new Data 1:new Data
' Bit 0 Error dedection 0:no Error 1: Error on i2c or Sensor
i2c.writeRegByte CCS811_I2C_ADR, STATUS_REG , 0
i2c.ReqFrom CCS811_I2C_ADR,1
CCS811temp = i2c.read

If CCS811temp and 8 then                               'if Bit3 of status_register =1 then DATA_available
 i2c.writeRegByte CCS811_I2C_ADR, ALG_RESULT_DATA ,0  'selects the Result mailbox
 i2c.ReqFrom CCS811_I2C_ADR, 8
 for i = 1 to 8                                       'The Result mailbox contains  8 Bytes
   BUFFER(i)  = i2c.read
 next
 eCO2 = 256*BUFFER(1) + BUFFER(2)    'eCO2 ppm
 TVOC = 256*BUFFER(3) + BUFFER(4)    'eTVOC
else
 eCO2 = 0
 TVOC = 0
end if



i2c.writeRegByte CCS811_I2C_ADR, STATUS_REG , 0  --- apparently STATUS_REG         = &h00 ?? from the forum?



Might be useful....
Edited 2021-02-15 03:37 by Nimue
Entropy is not what it used to be
 
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 425
Posted: 09:43pm 14 Feb 2021
Copy link to clipboard 
Print this post

After an enjoyable evening....

'CCS811 - Keystudio Sensor reading.
'Your sensor address might be diffent
'With help from Annex Wifi RDS forum
' Needs to run for a second to produce results

'Starts

dim as integer RDATA(7)

'Address of various buffers
CC811_ADR =     &h5A
APP_START_REG = &hF4
ALG_Results =   &h02
STATUS_REG =    &h00
MEAS_MOD_REG=   &h01

page write 1

'setup - this needs to happen once.  

i2c open 100,1000
pause 10

'Change from BOOT to APP Mode
i2c write CC811_ADR,0,1,APP_START_REG
pause 10

'Set meaure"  << This needs to be passed ONCE before the sensor will read
i2c write CC811_ADR,0,2,MEAS_MOD_REG,16
pause 10  

''Check the STATUS register (no actual check)
'i2c write CC811_ADR,0,1,STATUS_REG
'pause 10

i2c close

do
 
 i2c open 100,1000
 pause 20
 
 'Set meaure"

 'Check the results "envelope"
 i2c write CC811_ADR,0,1,ALG_Results
 
 pause 20
 
 i2c read CC811_ADR,0,8,RDATA()

 i2c close


'All the data in the resuls register  - uncomment to see
'for x= 0 to 7
'  print rdata(x),
'next x

print

 Print "ECO2 ",(256*RDATA(0))+RDATA(1), "TVOC ",(256*RDATA(2))+RDATA(3)

 page copy 1 to 0,B
 cls
 
 '250ms delay
 pause 250
   
loop


Not pretty, no GUI etc -- but the output for ECO2 and TVOC is consistent with sensor running on Arduino.

Now to tidy the code..
Entropy is not what it used to be
 
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 425
Posted: 10:16pm 14 Feb 2021
Copy link to clipboard 
Print this post

Or check Geoff's web site for AirQuality.Bas......   https://geoffg.net/AirQualityMonitor.html


DOH!
Entropy is not what it used to be
 
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 425
Posted: 03:25pm 16 Feb 2021
Copy link to clipboard 
Print this post

Great data sheet:  https://www.sciosense.com/wp-content/uploads/2020/01/SC-001232-DS-2-CCS811B-Datasheet-Revision-2.pdf
Entropy is not what it used to be
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025