Introduction
Air pollution is a significant concern worldwide, and measuring air quality has become more important than ever. The CCS811 VOC sensor is a powerful tool that can measure the concentration of volatile organic compounds (VOCs) in the air. With the help of an Arduino microcontroller, the sensor can be interfaced and used to create a system that can monitor the air quality in real time.
In this article, we will explore the basics of interfacing the “CCS811 VOC sensor with an Arduino” microcontroller and learn how to use it to measure air quality.
What is CCS811 VOC Sensor?
The CCS811 VOC sensor is a low-power, compact, and cost-effective air quality sensor that can detect the concentration of volatile organic compounds (VOCs) in the air. VOCs are emitted by various sources, including building materials, paints, cleaning agents, and human activities, and can cause significant health issues such as respiratory problems and headaches. The CCS811 sensor uses advanced sensing technology to measure the concentration of VOCs in parts per billion (ppb) and can also detect carbon dioxide (CO2) concentrations. The sensor can be interfaced with microcontrollers such as Arduino, making it a useful tool for creating air quality monitoring systems for indoor and outdoor environments.
Hardware Components
To interface CCS811 VOC Sensor with Arduino, you’ll need the following hardware components to get started:
Components | Value | Qty |
---|---|---|
Arduino UNO | – | 1 |
USB Cable Type A to B | – | 1 |
DC Power for Arduino | – | 1 |
VOC Sensor | CCS811 | 1 |
Jumper Wires | – | 1 |
CCS811 VOC Sensor Pinout
Pin No. | Pin Name | Pin Description |
---|---|---|
1 | ADDR | – Single address select bit to allow the alternate address to be selected. This helps you to connect two sensors and one I2C line. – When ADDR is low the 7 bit I²C address is decimal 90 / hex 0x5A – When ADDR is high the 7 bit I²C address is decimal 91 / hex 0x5B. |
2 | nRESET | nRESET is an active low input and is pulled up to VDD by default. nRESET is optional but external 4.7KΩ pull-up and/or decoupling of the nRESET pin may be necessary to avoid erroneous noise-induced resets. |
3 | nINT | nINT is an active low optional output. It is pulled low by the CCS811 to indicate the end of measurement or a set threshold value has been triggered. |
4 | PWM | Heater driver PWM output. Pins 4 and 5 must be connected together. |
5 | Sense | Heater current sense. Pins 4 and 5 must be connected together. |
6 | VDD | Supply voltage |
7 | nWAKE | nWAKE is an active low input and should be asserted by the host prior to an I²C transaction and held low throughout. |
8 | AUX | Optional AUX pin which can be used for ambient temperature sensing with an external NTC resistor. If not used, leave it unconnected. |
9 | SDA | SDA pin is used for I²C data. Should be pulled up to VDD with a resistor |
10 | SCL | SCL pin is used for I²C clock. Should be pulled up to VDD with a resistor |
EP | Exposed Pad | Connect to ground |
CCS811 VOC Sensor Arduino Circuit
Make connections according to the circuit diagram given below.
Wiring / Connections
Arduino | VOC Sensor |
---|---|
5V | VCC |
GND | GND |
A4 | SDA |
A5 | SCL |
GND | WAK |
Installing Arduino IDE
First, you need to install Arduino IDE Software from its official website Arduino. Here is a simple step-by-step guide on “How to install Arduino IDE“.
Installing Libraries
Before you start uploading a code, download and unzip the following libraries at /Program Files(x86)/Arduino/Libraries (default), in order to use the sensor with the Arduino board. Here is a simple step-by-step guide on “How to Add Libraries in Arduino IDE“.
Code
The Arduino code below reads the sensor data over I2C. The data will be printed on the serial terminal. Now copy the following code and upload it to Arduino IDE Software.
#include "Adafruit_CCS811.h" Adafruit_CCS811 ccs; void setup() { Serial.begin(9600); Serial.println("CCS811 test"); 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() { if(ccs.available()){ if(!ccs.readData()){ Serial.print("CO2: "); Serial.print(ccs.geteCO2()); Serial.print("ppm, TVOC: "); Serial.println(ccs.getTVOC()); } else{ Serial.println("ERROR!"); while(1); } } delay(500); }
Code Explanation
This Arduino code initializes and reads data from the CCS811 VOC sensor. It starts by including the “Adafruit_CCS811.h” library, which provides access to the functions necessary to communicate with the sensor.
In the “setup()” function, the code initializes the serial communication and prints a message to indicate that the CCS811 sensor is being tested. It then checks if the sensor has been properly initialized using the “ccs.begin()” function. If the sensor fails to start, the code prints an error message and enters an infinite loop.
Next, the code enters a while loop that waits for the sensor to be ready to read data. Once the sensor is ready, the “loop()” function is called. Within the loop function, the code checks if the sensor has data available using the “ccs.available()” function. If data is available, it reads the CO2 and TVOC concentrations using the “ccs.geteCO2()” and “ccs.getTVOC()” functions, respectively. The CO2 and TVOC concentrations are then printed to the serial monitor.
If there is an error while reading data from the sensor, the code prints an error message and enters an infinite loop. Finally, there is a delay of 500 milliseconds before the loop repeats, which ensures that the sensor is not read too frequently.
Applications
Here are some applications of the CCS811 VOC Sensor:
- Indoor air quality monitoring in homes, offices, and public buildings
- Smart HVAC systems that adjust airflow based on the air quality
- Industrial processes where VOC emissions need to be monitored and controlled
- Automotive cabin air quality monitoring systems
- Wearable devices that measure personal exposure to VOCs
- Smart agriculture systems that monitor VOC levels in greenhouses
- Air quality monitoring systems in cities and urban areas
- Environmental research projects that require accurate measurements of VOC levels in the air.
Conclusion
The CCS811 VOC sensor is an excellent tool for measuring air quality, and interfacing it with an Arduino microcontroller can create an efficient monitoring system. With this system, it is possible to measure and track VOC concentrations in the air and take steps to improve air quality.