Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
G6EJD committed Jul 12, 2018
1 parent 29f8433 commit b972311
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions Ardunio_CCS811.ino
@@ -0,0 +1,62 @@
/***************************************************************************
This is a library for the CCS811 air
This sketch reads the sensor
Designed specifically to work with the Adafruit CCS811 breakout
----> http://www.adafruit.com/products/3566
These sensors use I2C to communicate. The device's I2C address is 0x5A
Adafruit invests time and resources providing this open source code,
please support Adafruit andopen-source hardware by purchasing products
from Adafruit!
Written by Dean Miller for Adafruit Industries.
BSD license, all text above must be included in any redistribution
***************************************************************************/

#include "Adafruit_CCS811.h"

Adafruit_CCS811 ccs;

void setup() {
Serial.begin(115200);

Serial.println("CCS811 Reading CO2 and VOC");
Sensor_ON();
if(!ccs.begin()){
Serial.println("Failed to start sensor! Please check your wiring.");
while(1);
}
//calibrate temperature sensor
while(!ccs.available());
float temp = ccs.calculateTemperature();
ccs.setTempOffset(temp - 25.0);
}

void loop() {
if(ccs.available()){
float temp = ccs.calculateTemperature();
if(!ccs.readData()){
Serial.println("CO2: "+String(ccs.geteCO2())+"ppm, TVOC: "+String(ccs.getTVOC())+"ppb Temp:"+String(temp));
}
else{
Serial.println("Sensor read ERROR!");
ccs.readData();
}
}
delay(500);
}

void Sensor_ON(){
pinMode(A3,OUTPUT);
digitalWrite(A3, LOW);
}

void Sensor_OFF(){
pinMode(A3,OUTPUT);
digitalWrite(A3, HIGH);
}


0 comments on commit b972311

Please sign in to comment.