This is only a preview of the July 2023 issue of Practical Electronics. You can view 0 of the 72 pages in the full issue. Articles in this series:
|
Using Cheap Asian Electronic Modules
By Jim Rowe
MOS metal oxide semiconductor
Air Quality Sensors
In the last few years we’ve noticed the rise of low-cost air quality sensors
and sensing modules. In this article we’ll investigate some of the currently
available MOS (metal oxide semiconductor) type sensor modules, what
they offer and how to use/interface them with an Arduino Uno.
M
OS type air quality sensors
(sometimes called ‘MOx sensors’) rely on the behaviour of
particles of a metal oxide (usually tin
oxide) when heated in the presence
of air and/or other gases. The basic
principle is shown in Fig.1, which
depicts a cross-section of a typical
MOS sensor.
The silicon substrate of the sensing
chip has a thin layer of tin oxide on the
top, placed there by chemical vapour
deposition. Electrodes at each end
allow its resistance to be measured. On
the underside of the chip is a heater
element, used to heat the oxide layer
to around 200-250°C, to speed up the
sensor’s response.
When the oxide layer is heated in
the presence of clean air, donor electrons in the oxide attract oxygen molecules from the air, and they are ‘captured’ by the oxide particles. As a
result, a depletion layer forms on the
surface of the oxide layer, and its electrical resistance rises.
But if reducing gases such as carbon monoxide (CO) and some volatile
organic chemicals (VOCs) are present
in the air, oxygen molecules in the
surface of the oxide are released, and
the depletion layer becomes thinner.
As a result, the effective resistance of
the oxide layer is reduced.
So the current passed by the oxide
layer varies proportionally with the
amount of reducing gas in the air surrounding the oxide layer. The higher
36
the reducing gas level, the higher the
current. Therefore, the basic MOS sensor essentially behaves as a reducinggas-to-DC-analogue-current transducer.
The Hanwei MQ-135
Probably the most common of the
low-cost MOS sensors currently available is the Hanwei MQ-135, which is
designed to be sensitive to ammonia
(NH3), nitrous oxides (NOx), carbon
dioxide (CO2), alcohol, benzene and
smoke. Like the other sensors in the
Hanwei series, the MQ-135 sensor
comes in a cylindrical 6-pin package,
19mm in diameter and 15mm high.
Most modules using the MQ-135
simply take the current output from
the sensor and convert it to a proportional voltage using a fixed load resistor. The output voltage can then be
measured using a DMM, or fed into
one of the ADC inputs of a microcontroller unit (MCU).
Fig.2 shows the circuit of Hanwei’s
own air sensor module using the
MQ-135. The MQ-135’s heater pins (H)
are connected between the +5V (Vcc)
line and the GND line via a 5.1Ω series
current-limiting resistor.
One end of the tin oxide sensing
resistor (Rs) is connected to the +5V
line via the two A pins, and the other
end goes to the GND line via the two
B pins and a 1kΩ load resistor. The
two B pins are also connected to the
A0 analogue output pin, to allow the
voltage across the load resistor to be
sent to a DMM or an MCU’s ADC input.
The rest of the components are so
that the module can also be used as a
simple gas level alarm. One half of the
LM393 dual comparator (IC1b) compares the voltage across the 1kΩ load
resistor with a reference voltage set
using trimpot VR1, so whenever the
A0 voltage rises slightly above the
reference voltage, the output of IC1b
Fig.1: shows the
cross-section of a
MOS (metal oxide
semiconductor)
sensor and how it
works.
Practical Electronics | July | 2023
Fig.2: the circuit of Hanwei’s
MQ-135 air sensor module.
The lead photo shows a group
of MQ-model sensors.
(pin 7) drops to near ground level,
causing the D0 LED to begin glowing.
The voltage level at the D0 output
pin is pulled down simultaneously.
One change should ideally be made
to the module if you want to use it
with an MCU for monitoring the gas
level, rather than simply using it as a
gas level alarm. This involves replacing the sensor’s 1kΩ load resistor with
a 22kΩ resistor to give a higher output voltage swing and improve reading accuracy.
This resistor is an M2012/0805size (2.0 x 1.2mm) SMD component,
so you’ll need a fine-tipped soldering
iron and either a magnifying glass or
a microscope.
Fig.3 shows how to hook it up to
an Arduino Uno or a compatible MCU
after making that change. You just
need to connect the module’s Vcc and
GND pins to the corresponding pins
on the Arduino, plus the module’s A0
MQ-135 Sketch Program
void setup() {
Serial.begin(9600);
Serial.println(“Practical
Electronics MQ-135
demo!”);
}
void loop() {
int reading =
analogRead(A2);
Serial.println(reading);
delay(1000);
}
Sample Output
Practical Electronics MQ-135
demo!
696
694
694
691
692
710
Practical Electronics | July | 2023
pin to one of the Arduino’s ADC input
pins; in this case, we’re using A2.
There are quite a few Arduino libraries and sketches available to work with
the MQ-135 module. You’ll find links
to some of them in the list of links
at the end of this article. However,
I found many of them a bit tricky to
negotiate.
But I did find some very helpful information on Rob’s blog at:
https://blog.robberg.net/mq-135-arduino
Then I came across an elementary
sketch using no libraries, but just
showing the current analogue voltage
provided at the module’s A0 pin, see:
https://arduinolearning.com/amp/code
I adapted this sketch slightly, and
its listing is replicated below along
with some of the sample output from
when this sketch is running. When I
breathed on the MQ-135, that caused
the voltage reading to rise from under
700 to about 728 before falling back
down again.
As you can see, there’s no attempt
to convert the A0 voltage readings to
equivalent gas levels – for that, you
would need one of the fancier sketches
relying on their dedicated libraries.
SGX Sensortech MiCS-5524
Another MOS sensor found in low-cost
air/gas sensing modules is the MiCS5524, made by SGX Sensortech (an
Amphenol company) in Switzerland.
This is much smaller than the MQ-135,
coming in an SMD package measuring
only 7 x 5 x 1.6mm.
The MiCS-5524 detects CO, ethanol,
hydrogen, ammonia and methane. It
is used in an 18 x 13mm gas sensing
module with the same name available from various internet suppliers,
including ALiExpress, Mouser and
PiHut for around £10 to £15).
The circuit of the MiCS-5524 module is shown in Fig.4. It is essentially
just the sensor itself with an 82Ω current-limiting resistor for the sensor’s
heater and a 91kΩ load resistor for
its sensing resistor Rs, with a 100nF
capacitor across the latter to provide
noise reduction.
P-channel MOSFET Q1 is included
so that the power to the sensor can be
controlled using the module’s EN pin.
This pin can be left floating if the module is to operate continuously.
Fig.5 shows how easy it is to connect
the MiCS-5524 module to an Arduino
Uno, while the sketch is shown overleaf with the sample output. The sketch
is almost identical to the MQ-135
program and is similarly based on:
https://arduinolearning.com/amp/code
SGX Sensortech MiCS-VZ-89TE
SGX Sensortech also makes a fancier and slightly larger module (23
x 14mm) called the MiCS-VZ-89TE,
available from suppliers like element14, Digi-Key and Mouser for
around £20 plus delivery. This module incorporates its own dedicated
MCU with ADCs (analogue-to-digital converters) and embedded conversion algorithms.
As a result, this module can provide
both PWM and I2C digital outputs for
CO2 equivalent and TVOC (isobutylene equivalent).
I couldn’t find any circuit diagram
for the MiCS-VZ-89TE module, but its
layout is shown in Fig.6.
Fig.3: the connection diagram for
the MQ-135 sensor module with an
Arduino Uno or similar.
37
Fig.4: (left) the circuit diagram for the MiCS-5524 module, which is
simpler than the previous MQ-135 sensor and detects fewer gases. Next
to the circuit are two different modules that use this chip.
I found it fairly easy to connect to
this module. I used two 5-pin sections of SIL header strip, with the top
of the second and fourth pins of each
strip cut short, allowing the tops of the
remaining three pins to be soldered to
the notches on one side of the module. You can then plug the complete
assembly into a small breadboard for
testing and use.
Fig.7 shows how the MiCS-VZ-89TE
module can be connected to an Arduino Uno or equivalent MCU. The GND
connection goes to one of the Arduino’s GND pins, while the module’s
3.3V power connection goes to the
Arduino’s +3.3V pin.
The module’s I2C connections SDA
and SCL are wired to the Arduino’s
pins A4/SDA and A5/SCL, respectively. Each of these pins needs an
external 4.7kΩ pull-up resistor connected to the +3.3V pin, because the
MiCS-VZ-89TE module doesn’t provide pull-ups.
I found an Arduino sketch and
library to read the CO2 and VOC levels
from a MiCS-VZ-89TE, written by H
Grabas – it is available on his website at:
https://bit.ly/pe-jul23-grab
This sketch and its library worked
so well that I adapted it to produce the
sketch listed opposite, along with a
sample of the output from the Arduino
IDE Serial Monitor. For this to work,
you need to download Mr Grabas’
library from his website and install it
as a library in the Arduino IDE.
When running, it gives you a VOC
reading and a CO2 reading approximately once per second. I tried
breathing on the module’s sensor,
causing the VOC readings to rise
to around 270.4ppb (parts per billion), while the CO2 reading barely
moved from about 414 ppm (parts
per million).
Next, I sprayed a tiny amount
of isopropanol (spectacle cleaning
fluid) a few centimetres above the
sensor, causing the VOC reading to
jump up to its maximum figure of
1000ppb. So the MiCS-VZ-89TE and
the sketch and library certainly seem
to be working.
The ScioSense CCS811
Another MOS sensor found in several
low-cost air/gas sensing modules is
the CCS811, made by ScioSense BV
in Eindhoven, The Netherlands. The
CCS811 is in a tiny SMD package, measuring just 4 x 3 x 1.2mm.
Fig.6: the layout diagram for the
MiCS-VZ-89TE module.
MiCS-5524 Sketch
void setup() {
Serial.begin(9600);
Serial.println(“Practical
Electronics MiCs-5524
demo!”);
}
void loop() {
int reading =
analogRead(A0);
Serial.println(reading);
delay(1000);
}
Sample Output
Fig.5: MiCS-5524 connection diagram.
38
Practical Electronics MiCs5524 demo!
40
39
40
39
Fig.7: MiCS-VZ-89TE connection
diagram to an Arduino Uno.
Practical Electronics | July | 2023
MiCS-VZ-89TE Sketch:
Fig.8: the block diagram
for the CCS811 module.
One type of this module
is shown below, with a
larger variant shown
below.
#include <MICS-VZ-89TE.h>
#include <Wire.h>
MICS_VZ_89TE voc;
void setup() {
voc.begin();
Serial.begin(9600);
Serial.println(“Reading the
MiCS-VZ-89TE sensor”);
}
void loop() {
voc.readSensor();
Serial.print(“VOC =”);
Serial.print(voc.getVOC());
Serial.print(“ | ”);
Serial.print(“CO2 = ”);
Serial.println(voc.
getCO2());
delay(1000);
}
Sample Output
Reading the MiCS-VZ-89TE
sensor
VOC = 0.00
| CO2 = 413.97
VOC = 135.37 | CO2 = 413.97
VOC = 270.74 | CO2 = 413.97
VOC = 1000.00 | CO2 = 420.96
Despite its miniscule size, this sensor incorporates both an ADC and a
dedicated MCU with built-in conversion algorithms, plus an I2C digital
interface to link directly to a PC or
an MCU like an Arduino or a Micromite. It’s described by ScioSense as
an ‘ultra-low power digital gas sensor’ and detects a range of VOCs and
provide both eTVOC (equivalent
total VOC) and eCO 2 (equivalent
CO2) levels.
Fig.8 is a block diagram of the
CCS811. Pin 4 (PWM) and pin 5
(SENSE) must be connected together
for correct operation of the MOX
sensor’s heater control circuit. Pin 1
(ADDR) is to allow the CCS811’s I2C
address to be set to either 90d/5Ah
(ADDR pin low) or 91d/5Bh (ADDR
pin high), while the AUX pin (8) has
no internal connection.
The CCS811 sensor is used in many
air quality sensing modules, including the Keyestudio KS0457 CO2 Air
Quality module, the Duinotech SENCCS811 Air Quality Sensor module
(Jaycar Cat XC3782), the Adafruit
CCS811 Air Quality Sensor and the
CJMCU-811 CO2, Temperature and
Humidity Sensor from Banggood.
Fig.9 shows the circuit for many of
these CCS811 sensor modules. Along
with the CCS811 sensor itself, there’s
voltage regulator REG1, which steps
down the incoming +5V power to provide the 3.3V needed by the CCS811,
plus MOSFETs Q1 and Q2 which,
together with four 10kΩ pull-up resistors, perform logic-level conversion for
the I2C digital communication lines
(SDA and SCL).
Diodes D1 and D2, together with the
two 100kΩ pull-up resistors, allow the
WAKE and RST pins of the CCS811 to
be pulled low. The WAKE pin must
be pulled to ground to allow the chip
to operate.
Note that pin 1 of the CCS811 is
pulled low by a 100kΩ resistor to set
the I2C address to 90d/5Ah. Also, as
mentioned earlier, pins 4 and 5 are
tied together and pulled high via two
more 100kΩ resistors.
Incidentally, some CCS811-based
modules (such as the CJMCU-811)
have an additional pin on the I/O connector, with the extra pin connected
to pin 1 of the CCS811 and labelled
‘ADD’. This allows the I2C address of
the module to be changed to 91d/5Bh
by pulling the pin high.
It’s quite easy to connect the SENCCS811 and most of the other CCS811based air quality modules to an MCU
like an Arduino Uno, as shown in
Fig.10. The Vcc and GND pins connect to the +5V and GND pins of the
Fig.9: the circuit diagram for the
CCS811 module.
Practical Electronics | July | 2023
39
www.poscope.com/epe
Arduino, while the SDA pin goes to the
Arduino’s A4/SDA pin and the SCL pin
to the Arduino’s A5/SCL pin. Finally,
the module’s WAKE pin connects to
another GND pin on the Arduino.
Some modules have the pins in a different order, so make sure you check
the connections for the module you
are using.
Several Arduino libraries are available to support a sketch communicating with these modules. I found
the easiest one to use was the Keyestudio KS0457 library (CCS811.h
and CCS811.cpp), available from:
https://fs.keyestudio.com/KS0457
I also downloaded Keyestudio’s
readData.ino sketch and adapted it
to produce my own version of the
sketch: read_CCS811_data.ino. It’s a
bit too long to reproduce the listing
here, but you can download it from
the July 2023 page of the PE website at:
https://bit.ly/pe-downloads
- USB
- Ethernet
- Web server
- Modbus
- CNC (Mach3/4)
- IO
- PWM
- Encoders
- LCD
- Analog inputs
- Compact PLC
- up to 256
- up to 32
microsteps
microsteps
- 50 V / 6 A
- 30 V / 2.5 A
- USB configuration
- Isolated
PoScope Mega1+
PoScope Mega50
Shown below is the output of that
sketch. The Arduino provides a stream
of measurements for both the eCO2
level in ppm and eVOC in ppb.
At one point, I blew in the direction
of the CCS811 sensor to give it some
extra CO2. That’s the reason for the
sudden rise in eCO2 and eTVOC readings, from around 400ppm and 1-2ppb
up to peaks of 1743ppm and 384ppb
a second later. Then the readings fell
slowly after that.
Summary
After trying several of these modules,
I’m less keen on those based on the
MQ-135 sensor than on the Sensortech
MiCS sensors or the ScioSense CCS811
sensor. That’s mainly because of the
scarcity of easy-to-
understand software if you want to do more than simply ‘raise the alarm’ if the CO2/VOC
level rises above a preset ‘safe’ level.
I’m also not that keen on modules
based on the SGX Sensortech MiCS5524 sensor for much the same reason.
Overall, I prefer the ‘smarter’ modules like the SGX Sensortech MiCSVZ-89TE or most of those using the
CCS811 sensor. These modules are
all much easier to get going with an
MCU like an Arduino as a reliable
CO2/VOC sensor.
Sample Output
- up to 50MS/s
- resolution up to 12bit
- Lowest power consumption
- Smallest and lightest
- 7 in 1: Oscilloscope, FFT, X/Y,
Recorder, Logic Analyzer, Protocol
decoder, Signal generator
40
Getting data from the
CCS811...
eCO2: 400ppm, eTVOC: 0ppb
eCO2: 410ppm, eTVOC: 1ppb
eCO2: 414ppm, eTVOC: 2ppb
eCO2: 1743ppm, eTVOC: 384ppb
eCO2: 1345ppm, eTVOC: 143ppb
eCO2: 977ppm, eTVOC: 87ppb
Fig.10: CCS811 connection diagram.
I would give first prize to the
MiCS-VZ-89TE module (element14
2925865). But second prize would go
to any of the modules based on the
ScioSense CCS811 sensor, like the
Duinotech SEN-CCS811 from Jaycar
(Cat XC3782), the CJMCU-811 from
Banggood (ID 1157216), the Keyestudio KS0457 or the Adafruit CCS811:
www.adafruit.com/product/3566
I will describe some of the NDIR and
PAS type air quality sensor modules
in a future article.
Useful Links
MQ-135:
• www.arduinolibraries.info/
libraries/mq135
• https://github.com/
Phoenix1747/MQ-135
• siliconchip.com.au/link/abct
• https://blog.robberg.net/
mq-135-arduino
MiCS-5524:
• www.sgxsensortech.com
• siliconchip.com.au/link/abcu
• https://bit.ly/pe-jul23-grab
CCS811:
• https://fs.keyestudio.com/KS0457
• https://bit.ly/pe-jul23-811
Reproduced by arrangement with
SILICON CHIP magazine 2023.
www.siliconchip.com.au
Practical Electronics | July | 2023
|