Home Code CCS811 gas sensor and Raspberry Pi example

CCS811 gas sensor and Raspberry Pi example

by shedboy71

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

Sensor Information

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
Raspberry Pi Zero W Aliexpress product link

Amazon link

ebay link

CCS811 Gas Sensors Aliexpress product link

amazon link

ebay link

Connecting wire Aliexpress product link

Amazon.com link

Ebay link

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

[python]

#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)

[/python]

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

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More