Home Circuitpython Adafruit Feather M0 and CCS811 digital gas sensor circuitpython example

Adafruit Feather M0 and CCS811 digital gas sensor circuitpython example

by shedboy71

In this example we connect a CCS811 digital gas sensor to an Adafruit Feather M0 running Circuitpython

First lets look at some information about the chip from the manufacturer

The CCS811 is an ultra-low power digital gas sensor solution which integrates a metal oxide (MOX) gas sensor to detect a wide range of Volatile Organic Compounds (VOCs) for indoor air quality monitoring with a microcontroller unit (MCU), which includes an Analog-to-Digital converter (ADC), and an I²C interface.

CCS811 is based on ams unique micro-hotplate technology which enables a highly reliable solution for gas sensors, very fast cycle times and a significant reduction in average power consumption.

The integrated MCU manages the sensor driver modes and measurements. The I²C digital interface significantly simplifies the hardware and software design, enabling a faster time to market. The CCS811 supports intelligent algorithms to process raw sensor measurements to output equivalent total VOC (eTVOC) and equivalent CO2 (eCO2) values, where the main cause of VOCs is from humans.

The CCS811 supports multiple measurement modes that have been optimized for low-power consumption during an active sensor measurement and idle mode extending battery life in portable applications.

Features

Integrated MCU
On-board processing
Standard digital interface
Optimised low power modes
IAQ threshold alarms
Programmable baseline
Proven technology platform

Benefits

Managing the sensor drive modes and measurements while detecting VOCs
Provides indication of IAQ levels with no host intervention
Simple development for faster time to market
Extended battery life in portable applications
No need for continuous monitoring in software, reduces host power/processing
Stable and predictable behaviour regardless of air quality at power up
Most robust high temperature sensor platform on the market >100 million sense cycles and proven highest tolerance to ubiquitous siloxanes to ensure best long term reliability

Product parameters

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

This is an example of the sensor/module, there are many different options.

Parts Required

 

Name Link
Adafruit Feather M0 Express Adafruit (PID 3403) Feather M0 Express – Designed for CircuitPython – ATSAMD21 Cortex M0
CCS811 Gas Sensor Carbon Dioxide Detection Sensor Module CCS811
Connecting cables Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

 

Schematic/Connection

This is not the exact same module but the wiring is the same

feather and CCS811 layout

feather and CCS811 layout

Code Example

I used Mu for development

The following is based on a library , I copied the adafruit_ccs811 library for this device to the lib folder on my Feather M0 Express – https://circuitpython.org/libraries

This is the basic example which comes with the library

[codesyntax lang=”python”]

import time
import board
import busio
import adafruit_ccs811

i2c = busio.I2C(board.SCL, board.SDA)
ccs811 = adafruit_ccs811.CCS811(i2c)

# Wait for the sensor to be ready
while not ccs811.data_ready:
    pass

while True:
    print("CO2: {} PPM, TVOC: {} PPB".format(ccs811.eco2, ccs811.tvoc))
    time.sleep(0.5)

[/codesyntax]

Output

Here is what I saw in Mu REPL window

CO2: 400 PPM, TVOC: 0 PPB
CO2: 400 PPM, TVOC: 0 PPB
CO2: 400 PPM, TVOC: 0 PPB
CO2: 400 PPM, TVOC: 0 PPB
CO2: 400 PPM, TVOC: 0 PPB
CO2: 400 PPM, TVOC: 0 PPB
CO2: 400 PPM, TVOC: 0 PPB
CO2: 400 PPM, TVOC: 0 PPB

Links

Datasheet

You may also like

Leave a Comment