Getting Started with DFRobot’s CCS811 Air Quality Sensor Breakout Board
2021-11-17 | By Maker.io Staff
The CCS811 is a precise, small, and fast air quality sensor that measures the eCO2 (equivalent Carbon Dioxide) and TVOC (Total Volatile Organic Compounds) presence in indoor environments. Its low power requirements make it the ideal choice for a wide range of applications, such as HVAC systems and air purification devices. This article introduces the features of the DFRobot CCS811 Air Quality Sensor and demonstrates how to quickly get started using it.
The DFRobot CS811 is a tiny breakout module that makes it easy to employ the CCS811 Air Quality sensor in DIY projects.
Sensor Specifications and Features
The CCS811 is a heated-plate metal oxide sensor that features a small built-in microcontroller responsible for driving and controlling the sensor itself. Compared to other heated-plate sensors of this kind, the CCS811 features a low warm-up time. The sensor’s low power consumption makes it a perfect choice for battery-operated and mobile applications.
Apart from controlling the sensor itself, the built-in MCU also offers an I2C interface that allows other devices, such as an Arduino board, to conveniently read the sensor’s data without needing a custom communication protocol. Note that the CCS811 uses I2C clock stretching, which might cause problems and performance issues with some development boards, such as the Raspberry Pi.
The CCS811 responds to the eCO2 concentration with a range of 400 to 8192 ppm. It can detect the TVOC level in the environment within a range of zero to 1187 ppb. This sensor can detect Ethanol, Methanol, Aldehydes, Ketones, Organic Acids, Aliphatic and Aromatic Hydrocarbons, and Amines.
AMS, the manufacturer of the chip, recommends that the device be operated 48 hours before attempting to use it in an application. This break-in period is required because the sensor is known to change its level of sensitivity during the first few operating hours. This ensures that the sensor readings are accurate when the device is in use.
The onboard voltage regulator allows you to use the breakout board with any voltage between 3.3V and 5.5V. Note that the CCS811 previously had an internal thermistor for temperature sensing. This feature was removed in a more recent revision of the chip.
Hookup Guide
The I/O pins of this breakout module can be grouped into three categories. First, there are the power pins. VIN is the module’s positive voltage supply. As stated above, the breakout module works with any voltage between 3.3V and 5.5V. GND is the common ground for power and logic. Lastly, the 3V3 pin supplies a regulated 3.3V output from the onboard voltage regulator.
The board contains the SCL and SDA pins for I2C communication. Connect these pins to SCL and SDA, respectively, on your microcontroller.
Connect the DFRobot CCS811 breakout to an Arduino as shown in the schematic. Don't forget to pull the WAKE pin low to activate the device!
The breakout board exposes three additional pins for you to use. INT is an output interrupt signal that the sensor uses to let the external microcontroller know that a new sensor reading is available. The device can use this interrupt pin to warn the external microcontroller of dangerous conditions. The WAKE pin enables the sensor and can be connected to GND for use. The RST pin allows you to reset the sensor by pulling the pin low.
This breakout module also offers the option to change its I2C address. In its default configuration, the device has an I2C address of 0x45. Bridging the small jumper pads on the bottom side of the board changes its I2C address to 0x5B. Doing so can resolve conflicts and allow the use of multiple CCS811 sensors on a single I2C bus.
The underside of the PCB allows you to change the breakout module I2C address to resolve address conflicts.
A Software Example for Reading Sensor Values Using an Arduino
Start by installing the Adafruit_CCS811 library using the Arduino IDE’s library manager. Alternatively, you can also use DFRobot’s CCS811 library. However, I find that the Adafruit version is easier to install and that it works just as well with this breakout board. Either way, you should be able to determine the air quality:
#include "Adafruit_CCS811.h" // Create the sensor object Adafruit_CCS811 sensor; unsigned long lastRead = 0UL; void setup() { // Open a serial connection Serial.begin(9600); // Initialize the sensor and wait for it to start if(!sensor.begin()) { Serial.println("Failed to start the CCS811 sensor! Please check your wiring."); while(1); } // Wait for the sensor to be ready while(!sensor.available()); } void loop() { // Read the sensor every 500 milliseconds if(millis() - lastRead > 500) { // Check, whether the sensor is available and ready if(sensor.available()) { // Try to read some data. The if checks whether that // process was successful if(!sensor.readData()) { // If the sensor succeeded, output the measured values Serial.print("CO2: "); Serial.print(sensor.geteCO2()); Serial.print("ppm, TVOC: "); Serial.print(sensor.getTVOC()); Serial.print("ppb."); } else { // Otherwise, display that an error occured Serial.println("Error!"); } } } }
As shown, the setup() method initializes the serial interface and the CCS811 breakout module. Next, the sketch checks whether the initialization process was successful. The loop function first checks how much time has elapsed since it last read the sensor values. If more than 500 milliseconds have passed, the method requests the current sensor readings from the breakout module. If the request is successful, the program outputs the current sensor values to the serial console. Otherwise, it prints an error message.
The output of the Arduino sketch from above. This image shows how the CO2 level and the detected VOCs change as I blow on the sensor.
Summary
The CCS811 Air Quality Sensor is an impressive device with ultra-low power consumption and a fast heat-up process that makes it useful in a wide variety of applications. The DFRobot CS811 breakout module allows you to easily integrate the sensor into your DIY projects. The module uses the I2C protocol to communicate with external devices such as an Arduino. For that, you only need to connect two power lines and the two I2C communication wires. In addition, you must pull the WAKE pin low to enable the device. Once that’s completed, you can utilize the Adafruit CCS811 library to read the sensor values from an Arduino sketch, which manages to interface the device correctly.
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum