arduinoprojects

git clone https://git.tarina.org/arduinoprojects
Log | Files | Refs

yes.ino (591B)


      1 #include "Adafruit_CCS811.h"
      2 
      3 Adafruit_CCS811 ccs;
      4 
      5 void setup() {
      6   Serial.begin(9600);
      7 
      8   Serial.println("CCS811 test");
      9 
     10   if(!ccs.begin()){
     11     Serial.println("Failed to start sensor! Please check your wiring.");
     12     while(1);
     13   }
     14 
     15   // Wait for the sensor to be ready
     16   while(!ccs.available());
     17 }
     18 
     19 void loop() {
     20   if(ccs.available()){
     21     if(!ccs.readData()){
     22       Serial.print("CO2: ");
     23       Serial.print(ccs.geteCO2());
     24       Serial.print("ppm, TVOC: ");
     25       Serial.println(ccs.getTVOC());
     26     }
     27     else{
     28       Serial.println("ERROR!");
     29       while(1);
     30     }
     31   }
     32   delay(500);
     33 }