Lourdès Abou-tayeh / CCS811

Dependents:   Capteur2

Committer:
louatayehh
Date:
Mon Sep 06 11:32:22 2021 +0000
Revision:
1:d0abe05bc21e
Parent:
0:2c1dce3543ae
Capteur 2 : CSS811;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
louatayehh 0:2c1dce3543ae 1 #include "mbed.h"
louatayehh 0:2c1dce3543ae 2 #include "CCS811.h"
louatayehh 0:2c1dce3543ae 3
louatayehh 0:2c1dce3543ae 4 I2C i2c (I2C_SDA,I2C_SCL);
louatayehh 1:d0abe05bc21e 5 Serial bluetooth(p9,p10);
louatayehh 0:2c1dce3543ae 6
louatayehh 0:2c1dce3543ae 7 #ifdef TARGET_UBLOX_EVK_ODIN_W2
louatayehh 0:2c1dce3543ae 8 CCS811 ccs811(p9, p10);
louatayehh 0:2c1dce3543ae 9 #else
louatayehh 0:2c1dce3543ae 10 CCS811 ccs811(I2C_SDA, I2C_SCL);
louatayehh 1:d0abe05bc21e 11 #endif
louatayehh 0:2c1dce3543ae 12
louatayehh 0:2c1dce3543ae 13 uint16_t eco2, tvoc;
louatayehh 0:2c1dce3543ae 14
louatayehh 0:2c1dce3543ae 15
louatayehh 0:2c1dce3543ae 16 void CCS811Callback(void)
louatayehh 0:2c1dce3543ae 17 {
louatayehh 0:2c1dce3543ae 18 bluetooth.baud(56000);
louatayehh 0:2c1dce3543ae 19 //ccs811.readData(&eco2, &tvoc);
louatayehh 0:2c1dce3543ae 20 //bluetooth.printf("eCO2 reading :%dppm, TVOC reading :%dppb\r\n", eco2, tvoc);
louatayehh 1:d0abe05bc21e 21
louatayehh 0:2c1dce3543ae 22 ccs811.readData(&eco2, &tvoc);
louatayehh 0:2c1dce3543ae 23 bluetooth.printf("eCO2 reading :%dppm", eco2);
louatayehh 0:2c1dce3543ae 24 }
louatayehh 0:2c1dce3543ae 25
louatayehh 0:2c1dce3543ae 26 int main()
louatayehh 0:2c1dce3543ae 27 {
louatayehh 0:2c1dce3543ae 28 bluetooth.baud(56000);
louatayehh 0:2c1dce3543ae 29 ccs811.init();
louatayehh 0:2c1dce3543ae 30 wait(1);
louatayehh 0:2c1dce3543ae 31
louatayehh 1:d0abe05bc21e 32 while(1)
louatayehh 1:d0abe05bc21e 33 {
louatayehh 0:2c1dce3543ae 34 ccs811.readstatus(); //0x90 reports everything working, 0x98 measurement ready to be used
louatayehh 0:2c1dce3543ae 35 wait(1);
louatayehh 0:2c1dce3543ae 36 CCS811Callback();
louatayehh 0:2c1dce3543ae 37 wait(1);
louatayehh 0:2c1dce3543ae 38 }
louatayehh 0:2c1dce3543ae 39 }