Categories

Follow Us

CCS811 digital gas sensor and Arduino example

In this example we will connect a CCS811 gas sensor to an arduino, lets look at the sensor

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

 

 

Amount Part Type
1 CJMCU-811 CCS811 Air Quality Gas Sensor
1 UNO R3 CH340G/ATmega328P, compatible for Arduino UNO R3

 

 

Schematics/Layout

 

Remember and connect WAKE to gnd

arduino and ccs811 layout

arduino and ccs811 layout

 

arduino and ccs811 schematic

arduino and ccs811 schematic

Code

Again we use a library this is the adafruit one – you can use the library manager and add this.

And this is the out of the box example

#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);
}
//calibrate temperature sensor
while(!ccs.available());
float temp = ccs.calculateTemperature();
ccs.setTempOffset(temp - 25.0);
}
void loop() {
if(ccs.available()){
float temp = ccs.calculateTemperature();
if(!ccs.readData()){
Serial.print("CO2: ");
Serial.print(ccs.geteCO2());
Serial.print("ppm, TVOC: ");
Serial.print(ccs.getTVOC());
Serial.print("ppb Temp:");
Serial.println(temp);
}
else{
Serial.println("ERROR!");
while(1);
}
}
delay(500);
}

 

Output

Open the serial monitor – this is what I saw. The higher CO2 level was when I breathed on the sensor

CO2: 400ppm, TVOC: 0ppb Temp:28.28
CO2: 400ppm, TVOC: 0ppb Temp:47.75
CO2: 400ppm, TVOC: 0ppb Temp:25.00
CO2: 400ppm, TVOC: 0ppb Temp:26.49
CO2: 1228ppm, TVOC: 126ppb Temp:25.68
CO2: 575ppm, TVOC: 26ppb Temp:9.59
CO2: 400ppm, TVOC: 0ppb Temp:26.49
CO2: 400ppm, TVOC: 0ppb Temp:105.81

 

Video

In this video we import the library, we compile and program the Arduino and then we open the serial monitor. The higher reading is when I blew on the sensor

Links

ccs811 datasheet

CJMCU-811 CCS811 Air Quality Gas Sensor

Share

MQ-135 gas sensor

MQ-135 gas sensor is a hazardous gas detection apparatus for the family, the environment, suitable for ammonia, aromatic compounds, sulfur, benzene vapor, smoke and other gases harmful gas detection, gas-sensitive element test concentration.

Air quality sensor is for detecting a wide range of gases, including NH3, NOx, alcohol, benzene, smoke and CO2. Ideal for use in office or factory, simple drive and monitoring circuit.

The sensitivity of the sensor can be adjusted by using the potentiometer.

MQ-135

MQ-135

FEATURES
* High sensitivity to Sulfide, benzene Department of steam, smoke and other harmful gases
* Long life and low cost
* Simple drive circuit

Connection

here are the connections for my sensor

Arduino Gas Sensor
5V VCC
GND GND
NC DO
Analog A0 AO

Code

void setup() 
{
  Serial.begin(9600);
}
 
void loop() 
{
  float sensorVoltage; 
  float sensorValue;
 
  sensorValue = analogRead(A0);
  sensorVoltage = sensorValue/1024*5.0;
 
  Serial.print("sensor voltage = ");
  Serial.print(sensorVoltage);
  Serial.println(" V");
  delay(1000);
}

Results

Again look at the serial monitor, you need to let the sensor stabilise. Remember it consists of a heating element, so you effectively have to let the sensor ‘heat up’.

sensor voltage = 0.30 V
sensor voltage = 0.31 V
sensor voltage = 0.33 V
sensor voltage = 0.34 V
sensor voltage = 0.35 V
sensor voltage = 0.32 V
sensor voltage = 0.31 V
sensor voltage = 0.30 V

Links

Mq-135 datasheet

 
MQ-135 Air Quality Sensor Hazardous Gas Detection Module for Arduino

Share

MQ-9 gas sensor

MQ-9 gas sensor has high sensitity to Carbon Monoxide, Methane and LPG. The sensor could be used to detect different gases contains CO and combustible gases, it is with low cost and suitable for different application.

The sensitivity of the sensor can be adjusted by using the potentiometer.

MQ-9

MQ-9

FEATURES

* Good sensitivity to CO/Combustible gas
* High sensitivity to Methane, Propane and CO
* Long life and low cost
* Simple drive circuit

Connection

here are the connections for my sensor

Arduino Gas Sensor
5V VCC
GND GND
NC DOUT
Analog A0 AOUT

Code

void setup() 
{
  Serial.begin(9600);
}
 
void loop() 
{
  float sensorVoltage; 
  float sensorValue;
 
  sensorValue = analogRead(A0);
  sensorVoltage = sensorValue/1024*5.0;
 
  Serial.print("sensor voltage = ");
  Serial.print(sensorVoltage);
  Serial.println(" V");
  delay(1000);
}

Results

Again look at the serial monitor, you need to let the sensor stabilise. Remember it consists of a heating element, so you effectively have to let the sensor ‘heat up’.

sensor voltage = 0.40 V
sensor voltage = 0.40 V
sensor voltage = 0.40 V
sensor voltage = 0.42 V
sensor voltage = 0.41 V
sensor voltage = 0.41 V
sensor voltage = 0.41 V
sensor voltage = 0.41 V
sensor voltage = 0.40 V

Links

Mq-9 datasheet
MQ-9 Combustible Gas Detector Carbon Monoxide CO Sensor Module for Arduino

Share

MQ8 Gas Sensor

The MQ8 Gas Sensor module is useful for gas leakage detection. They are used in gas leakage detecting equipments in home and industry, are suitable for detecting of Hydrogen.  Due to its high sensitivity and response time, measurements can be taken as soon as possible.

Try and avoid alcohol, LPG,cooking fumes as the sensor has slight sensitivity to these substances and this may affect results

The sensitivity of the sensor can be adjusted by using the potentiometer.

MQ-8

MQ-8

FEATURES

* High sensitivity to Hydrogen
* Small sensitivity to alcohol, LPG,cooking fumes
* Fast response .
* Stable and long life
* Simple drive circuit

Connection

here are the connections for my sensor

Arduino Gas Sensor
5V VCC
GND GND
NC DO
Analog A0 AO

Code

void setup() 
{
  Serial.begin(9600);
}
 
void loop() 
{
  float sensorVoltage; 
  float sensorValue;
 
  sensorValue = analogRead(A0);
  sensorVoltage = sensorValue/1024*5.0;
 
  Serial.print("sensor voltage = ");
  Serial.print(sensorVoltage);
  Serial.println(" V");
  delay(1000);
}

Results

Again look at the serial monitor, you need to let the sensor stabilise. Remember it consists of a heating element, so you effectively have to let the sensor ‘heat up’.

sensor voltage = 0.58 V
sensor voltage = 0.58 V
sensor voltage = 0.58 V
sensor voltage = 0.57 V
sensor voltage = 0.60 V
sensor voltage = 0.67 V
sensor voltage = 0.67 V
sensor voltage = 0.70 V
sensor voltage = 0.70 V
sensor voltage = 0.66 V
sensor voltage = 0.64 V

 

Links

MQ8 datasheet
MQ8 Hydrogen Gas Sensor H2 Detection Sensor Module Gas Sensor for Arduino

Share