Zuno CCS811 Library

This is a library for the CCS811 I2C gas sensor breakout. CCS811 is a gas sensor that can detect a wide range of Volatile Organic Compounds (VOCs) and is intended for indoor air quality monitoring. The CCS811 has a 'standard' hot-plate MOX sensor, as well as a small microcontroller that controls power to the plate, reads the analog voltage, and provides an I2C interface to read from. This part will measure eCO2 (equivalent calculated carbon-dioxide) concentration within a range of 400 to 8192 parts per million (ppm), and TVOC (Total Volatile Organic Compound) concentration within a range of 0 to 1187 parts per billion (ppb). According to the fact sheet it can detect Alcohols, Aldehydes, Ketones, Organic Acids, Amines, Aliphatic and Aromatic Hydrocarbons. Please note, this sensor, like all VOC/gas sensors, has variability and to get precise measurements you will want to calibrate it against known sources! That said, for general environmental sensors, it will give you a good idea of trends and comparisons. AMS recommends that you run this sensor for 48 hours when you first receive it to "burn it in", and then 20 minutes in the desired mode every time the sensor is in use. This is because the sensitivity levels of the sensor will change during early use The library works with the sensor using Wire in the description of this library, see the peripherals used and the pins used.
		
#include "Arduino.h"
#include "ZUNO_CCS811.h"

#define MY_SERIAL		Serial

ZUNO_CCS811 ccs;

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

	MY_SERIAL.println("CCS811 test");
	delay(100);
	if(!ccs.begin()){
		MY_SERIAL.println("Failed to start sensor! Please check your wiring.");
		while(1)
			delay(100);
	}
	MY_SERIAL.println("begin ok");

	// Wait for the sensor to be ready
	while(!ccs.available()){
		delay(100);
	};
}

void loop() {
	if(ccs.available()){
		if(!ccs.readData()){
			MY_SERIAL.print("CO2: ");
			MY_SERIAL.print(ccs.geteCO2());
			MY_SERIAL.print("ppm, TVOC: ");
			MY_SERIAL.println(ccs.getTVOC());
		}
		else{
			MY_SERIAL.println("ERROR!");
			while(1)
				delay(100);
		}
		
	}
	delay(500);
}