The Adafruit CCS811 is an advanced gas sensor designed to detect a wide range of Volatile Organic Compounds (VOCs) and equivalent carbon dioxide (eCO2) levels. This sensor is ideal for monitoring indoor air quality in various environments such as homes, offices, and industrial spaces. The CCS811 is a digital sensor that communicates over an I2C interface, making it easy to integrate with microcontrollers like the Arduino UNO.
Pin Number | Pin Name | Description |
---|---|---|
1 | VDD | Supply Voltage (3.3V to 5V) |
2 | GND | Ground |
3 | SDA | I2C Data |
4 | SCL | I2C Clock |
5 | WAKE | Wake Pin (active low) |
6 | INT | Interrupt Pin |
7 | RST | Reset Pin (active low) |
8 | ADDR | I2C Address Select (float or connect to GND) |
#include <Wire.h>
#include <Adafruit_CCS811.h>
Adafruit_CCS811 ccs;
void setup() {
Serial.begin(9600);
Wire.begin();
// Initialize the sensor
if (!ccs.begin()) {
Serial.println("Failed to start sensor! Please check your wiring.");
while (1);
}
// Wait for the sensor to be ready
while (!ccs.available());
}
void loop() {
// Read sensor data when available
if (ccs.available()) {
if (!ccs.readData()) {
Serial.print("CO2: ");
Serial.print(ccs.geteCO2());
Serial.print("ppm, TVOC: ");
Serial.print(ccs.getTVOC());
Serial.println("ppb");
} else {
Serial.println("ERROR!");
// If reading the sensor data failed, print an error message
}
}
delay(500); // Wait for 500 ms before reading again
}
Q: Can the CCS811 sensor measure CO2 directly? A: No, the CCS811 measures eCO2 levels, which are calculated based on detected VOCs and not a direct measurement of CO2.
Q: How long does the sensor need to preheat? A: The sensor should preheat for at least 20 minutes upon first use or after a prolonged period of inactivity.
Q: Is the sensor compatible with 5V logic? A: The sensor can be powered by 5V, but the logic level for I2C communication is 3.3V. Use level shifters if necessary.
Q: Can I use multiple CCS811 sensors on the same I2C bus? A: Yes, but you will need to set different I2C addresses using the ADDR pin for each sensor.