|
Forum Index : Microcontroller and PC projects : CCS811 CO2 I2C sensor - CMM2
| Author | Message | ||||
| Nimue Guru Joined: 06/08/2020 Location: United KingdomPosts: 425 |
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 KingdomPosts: 425 |
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 KingdomPosts: 425 |
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 "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 KingdomPosts: 425 |
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 KingdomPosts: 425 |
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 |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |