CCS811 gas sensor and Raspberry Pi example

In this article we will connect a CCS811 gas sensor to an Raspberry Pi

CCS811 is a low-power digital gas sensor solution, which integrates a gas sensor solution for detecting low levels of VOCs typically found indoors, with a microcontroller unit (MCU) and an Analog-to-Digital converter to monitor the local environment and provide an indication of the indoor air quality via an equivalent CO2 or TVOC output over a standard I2C digital interface.


Integrated MCU
On-board processing
Standard digital interface
Optimised low power modes
IAQ threshold alarms
Programmable baseline
2.7mm x 4.0mm LGA package
Low component count
Proven technology platform


Interface I²C
Supply Voltage [V] 1.8 to 3.6
Power Consumption [mW] 1.2 to 46
Dimension [mm] 2.7 x 4.0 x 1.1 LGA
Ambient Temperature Range [°C] -40 to 85
Ambient Humidity Range [% r.h.] 10 to 95


Parts List

Name Link
Pi Zero Raspberry Pi Zero W (Wireless) (new 2017 model)
CCS811 CCS811 Carbon Monoxide CO VOCs Air Quality Numerical Gas Sensors
Connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire


We chose a Pi Zero, any Raspberry Pi should work just fine.


pi and CCS811
pi and CCS811


The example library and code examples come from

I used the example

<pre>#this example reads and prints CO2 equiv. measurement, TVOC measurement, and temp every 2 seconds

from time import sleep
from Adafruit_CCS811 import Adafruit_CCS811

ccs =  Adafruit_CCS811()

while not ccs.available():
temp = ccs.calculateTemperature()
ccs.tempOffset = temp - 25.0

	if ccs.available():
	    temp = ccs.calculateTemperature()
	    if not ccs.readData():
	      print "CO2: ", ccs.geteCO2(), "ppm, TVOC: ", ccs.getTVOC(), " temp: ", temp

	      print "ERROR!"

you can run this by typing the following in the terminal

sudo python


In the terminal you should see something like this


Previous articleADXL362 3-axis accelerometer and Raspberry Pi example
Next articleraspberry pi default password