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.

Features

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

Specs

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

Schematic

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

 

pi and CCS811
pi and CCS811

Code

The example library and code examples come from https://github.com/adafruit/Adafruit_CCS811_python

I used the CCS811_example.py 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():
	pass
temp = ccs.calculateTemperature()
ccs.tempOffset = temp - 25.0

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

	    else:
	      print "ERROR!"
	      while(1):
	      	pass
	sleep(2)</pre>

you can run this by typing the following in the terminal

sudo python CCS811_example.py

Output

In the terminal you should see something like this

Links

https://ams.com/documents/20143/36005/CCS811_DS000459_6-00.pdf

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