This is only a preview of the November 2022 issue of Silicon Chip. You can view 43 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Christmas LED Icicle Decoration":
Items relevant to "LC Meter Mk3":
Items relevant to "DC Supply Transient Filter":
Items relevant to "Active Monitor Speakers, Part 1":
Items relevant to "WiFi-Synchronised Analog Clock":
Items relevant to "Particulate Matter (PM) Sensors":
Items relevant to "30V 2A Bench Supply, Part 2":
Purchase a printed copy of this issue for $11.50. |
Using Electronic Modules with Jim Rowe
PM (particulate matter)
“Dust” Sensors
In this last article on low-cost air quality sensors, we look more closely at
particulate matter (PM) sensors, also called “dust” or “smoke” sensors.
A
s mentioned in the first of these
articles, PM sensors fall into three
groups based on the size of the particles they are designed to detect: less
than 10μm (PM10), less than 2.5μm
(PM2.5) and less than 1μm (PM1.0).
Currently, PM2.5 types are the most
common in the low-cost section of the
market, so we’ll concentrate on modules that support it.
The basic principle of the most
common type of PM sensor is shown
in Fig.1. This was described in the
first article but we’ll briefly go over
it again. A small fan pulls air from
the surrounding environment into a
channel which passes through a sensing chamber. A laser sends a focused
beam of light through the chamber,
and any particles in the air scatter the
light towards the sides of the chamber.
One or more photodiodes detect
this scattered light on the sides of the
chamber. Any light not scattered by
particles passes through the chamber
to be absorbed by the ‘beam dump’.
By controlling the fan speed and
thus moving the air through the sensing chamber at a known rate of volume and measuring the photodiodes’
output, the concentration of particles
in the air can be calculated.
The result is in terms of μg/m3
(micrograms per cubic metre), because
the traditional and most accurate way
of measuring PM is the ‘gravimetric’
method. This involves using a preweighed clean filter to collect particles from the air over a 24-hour sampling period, then weighing the filter
again to determine the total mass of the
accumulated particles in micrograms.
The concentration is then obtained
by dividing this figure by the total volume of air that passed through the filter
during the 24-hour sampling period.
Available PM modules
There are several low-cost PM sensors currently available, including the
Grove-Laser Sensor module, based on
the Seeed Studio HM3301 sensor from
Shenzhen, China, and the SN-GCJA5
sensor made by Panasonic Photo and
Lighting Co in Osaka, Japan.
The first is a fan-type sensor, as
shown in Fig.1. But other types of
PM sensor modules do not have an
internal fan, including the Panasonic
SN-GCJA5 and the XC3780 from Jaycar,
The Grove-Laser air sensor module is based on the Seeed
HM3301 particulate matter sensor. The sensor itself measures 38
x 40 x 15mm and the module comes with a suitable cable.
Fig.1: the basic operating principle of a particular matter (PM) sensor. Air is drawn through a chamber with a laser beam,
and any laser light scattered by particles in the air is picked up by one or more photodiodes.
78
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
Fig.2: the components of the HM3301 sensor. The part at left is basically identical
to what’s shown in Fig.1, while the section at right shows the electronics that pick
up the scattered light level and turn it into a digital measurement.
based on the Sharp GP2Y1010AU sensor. We will look at all three of these
sensor modules in this article.
The Grove-Laser module
The Seeed Studio HM3301 sensor
comes inside a compact plastic and
metal case measuring 38 × 40 × 15mm.
In addition to the fan, laser and photodiodes, it has built-in electronics that
provide fan control, photodiode signal
amplification, filtering, multi-channel
data acquisition and an MCU (microcontroller unit) for data processing.
The output is via a two-wire I2C serial
interface.
In the Grove-Laser module, the
HM3301 sensor is mounted on a PCB
measuring 80 × 40mm, with a four-pin
connector at one end for connections
to a 3.3-5V power supply and the I2C
lines for connection to a PC or an external MCU. The effective PM2.5 measuring range of the module is 1-500μg/m3,
although it can measure up to a maximum level of 1000μg/m3.
This module is available from
Australian distributor Pakronics in
Rosanna, Vic for $46.06 plus shipping
and GST, totalling $62.07.
Fig.2 shows a functional block diagram of what’s inside the HM3301 sensor. The actual PM measuring section
with the fan, laser, detection chamber,
and photodiode detector is on the left.
On the right is the electronics section
with its filter/amplifier, multi-channel
acquisition and internal MCU for digital signal processing and the I2C data
communication interface.
Since the HM3301 sensor operates
from a 3.3-5V DC supply and has a
standard I2C interface, connecting
the module to an Arduino module or
similar is relatively straightforward. A
sample connection scheme is shown
in Fig.3.
Note that although the HM3301
sensor itself has no internal pull-up
resistors on the SDA or SCL lines, the
Grove-Laser module provides pull-up
resistors plus logic-level converters on
its PCB. That’s why the connections
shown in Fig.3 are so straightforward.
Of course, wiring the module up is
only part of the story. You also need
software that can communicate with it
and display the results. So if you want
to use it with an Arduino, you’ll need
both a matching library and a sketch
designed to communicate with the
HM3301 sensor using it.
When I went to the “Reference”
section of the Arduino website and
scrolled down through the Libraries/
Sensors list, I found a library that had
clearly been produced to do the job:
“grove-laser-pm2.5-sensor-hm3301”.
And when I clicked on “Read the documentation” on its page, it took me to
GitHub, where I found both the documentation and a link to download the
library (v1.0.2).
After downloading and installing
the library, I found that it came with an
example program called “basic_demo.
ino”. After verifying and uploading
that program ‘sketch’ to an Arduino
Uno connected to the Grove-Laser
Fig.3: connecting the
Grove HM3301 module
to an Arduino is
simple. All it needs is
a ground connection,
a 5V DC supply and
the SDA and SCL pins
connected to an I2C
bus.
Fig.4: HM3301 sample output
siliconchip.com.au
08:46:39.046 -> sensor num: 0
08:46:39.046 -> PM1.0 concentration(CF=1,Standard
particulate matter, unit:ug/m3): 404
08:46:39.046 -> PM2.5 concentration(CF=1,Standard
particulate matter, unit:ug/m3): 850
08:46:39.046 -> PM10 concentration(CF=1,Standard
particulate matter, unit:ug/m3): 1356
08:46:39.046 -> PM1.0 concentration(Atmospheric
environment,unit:ug/m3): 266
08:46:39.046 -> PM2.5 concentration(Atmospheric
environment,unit:ug/m3): 524
08:46:39.046 -> PM10 concentration(Atmospheric
environment,unit:ug/m3): 776
module as per Fig.3, the Arduino IDE’s
Serial Monitor (set to a baud rate of
115,200) sprang into life.
I immediately saw the text shown in
Fig.4, with two sets of PM1.0, PM2.5
and PM10 measurements appearing
every five seconds.
The example output shown in Fig.4
is higher than normal (it should be just
above zero). That’s because I struck
a match and blew it out just before
that, blowing the smoke towards the
HM3301 sensor. The readings jumped
up quite quickly but went back to normal after about 10 seconds.
So while it’s not particularly low in
cost, the Grove-Laser PM module is
easy to use and seems quite sensitive.
Panasonic SN-GCJA5 sensor
similar to the HM3301 sensor innards
shown in Fig.2, apart from not having any internal fan to move the air
through the detection chamber.
Since it has an I2C interface, it connects to an MCU like the Arduino in
much the same way as the Grove-Laser
module, as shown in Fig.6. But there’s
one small but significant problem: connections to the SN-GCJA5 sensor are
all made via a tiny 5-pin ‘pico’ connector at one end, but a connection
cable with a matching plug is not supplied with it.
So if you want to use – or even try
out – the sensor, you first need to
obtain a matching cable.
Panasonic’s data sheet for the
SN-GCJA5 sensor states that its connector is made by JST (Japan Solderless Terminals) Manufacturing
Company, and has the type number SM05B-GHS-TB(LF)(SN). I had
a lot of trouble finding any compatible cables – most cables I found with
similar connectors turned out to have
pins either 1.0mm or 1.5mm apart, not
the 1.25mm of the JST SM05B-GHSTB(LF)(SN).
Just as I was on the brink of concluding that I would not be able
to try out the SN-GCJA5 sensor,
Silicon Chip’s Editor emailed me to
say that he believed he had found
a supplier of compatible cables on
AliExpress (www.aliexpress.com/
item/33005797784.html). I quickly
checked them out and then ordered
a pack of 10 (the smallest quantity).
These cost $18.20 including postage
and GST, and they took quite a few
weeks to arrive.
But they did finally arrive, and I
used one (or half of one, to be precise)
to hook up the sensor to an Arduino
and try it out.
It was again necessary to find a suitable Arduino library to communicate
with the SN-GCJA5. Luckily, I found
one in the Reference section on the
Arduino website, under siliconchip.
au/link/abep
When I downloaded this library
and installed it, I found that it again
included some example sketches. The
first of these was called “Example1_
BasicReadings.ino”. When I verified
and uploaded this sketch to the Arduino Uno connected to the SN-GCJA5
sensor, as shown in Fig.6, it finally
sprang into life. Once again, I had to
set the Arduino IDE Serial Monitor to
115,200 baud.
You can see the output of the sketch
►
The Panasonic SN-GCJA5 sensor
is again mounted inside a compact
moulded plastic box that measures
37 × 37 × 12mm and weighs 13g. As
with the HM3301 sensor, it includes
electronics to control the laser and
amplify and filter the signals from the
photodiodes, plus an MCU for data
processing.
The output is via either an I2C or
a UART TX terminal. The effective
measuring range of this module is
0-2000μg/m3.
The Panasonic SN-GCJA5 sensor is
currently available in Australia from
element14 for $33.56 plus delivery
and GST, giving a total of $53.42 (less
if you buy it along with enough other
stuff, such as a second sensor, to get
free delivery).
Fig.5 shows what is inside the
SN-GCJA5 sensor. As you can see, it’s
External connections to
the SN-GCJA5 sensor
are via a tiny 5-way JST
connector with 1.25mm
pin spacing. No matching
cable is supplied, which
is a bit of a problem as
they are hard to find!
Fig.5: the Panasonic SN-GCJA5-PM sensor does not use a fan. It
instead relies on passive diffusion of air through its sensing channel.
Otherwise, its structure is similar to the HM3301 shown in Fig.2.
The Panasonic SN-GCJA5 particulate matter sensor is in a small
moulded plastic case measuring 37 x 37 x 12mm. In addition to
the laser and photodetector, it contains all of the electronics and
provides both I2C and UART digital outputs.
80
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
Fig.6: connecting the Panasonic SN-GCJA5
module to an Arduino is again simple. All you
need to do is connect a 5V DC supply, a ground
connection and the I2C bus via the SCL and SDA
pins. Pin 1 isn’t used for anything, nor does it
have any function.
Fig.7: SN-GCJA5 sample output
08:03:23.189
08:03:23.189
08:03:23.189
7.5, 10,
08:03:23.236
08:04:18.209
08:04:28.238
146,4,
08:04:48.249
08:05:58.231
in Fig.7. It gives three PM readings
(1.0, 2.5 and 10) at the start of each
sample line, followed by six Count
figures (labelled 0.5, 1, 2.5, 5, 7.5 and
10). The first three figures are the ‘mass
densities’ for the three main particle
categories, while the later figures are
‘particle counts’ for all six particle size
categories.
Looking at Fig.7, the first values outputted are pretty low, they then shoot
up to much higher levels after I lit a
match about 150mm from the sensor and then blew it out, blowing the
smoke towards the sensor.
So the Panasonic SN-GCJA5 sensor does work, and even works quite
well, once you manage to find a suitable cable to connect to it. It would be
-> Panaosnic SN-GCJA5 Example
-> Sensor started
-> PM:1.0, 2.5, 10, Counts: 0.5, 1, 2.5, 5,
-> 2.79,3.12,3.50,5,32,4,0,0,0,
-> 57.99,135.45,448.29,39,598,801,13,71,2,
-> 1370.39,1730.99,2392,60,440,3824,3759,37,
-> 139.76,154.51,173.83,513,1210,153,1,2,0,
-> 62.35,73.86,83.09,200,591,120,1,0,0,
a lot easier if they supplied a matching cable!
The Jaycar XC3780 sensor
As mentioned earlier, Jaycar’s
XC3780 dust sensor module is based
on the Sharp GP2Y1010AU fanless
sensor. The sensor itself is pretty compact, measuring 46 × 30 × 17.5mm,
and the XC3780 module is only a little larger, at 62 × 35 × 19mm. 7.5mm
diameter holes in the top and bottom
of the sensor (and the PCB) allow air
containing any particulate matter, dust
or smoke to diffuse through the sensor.
At the time of writing, the XC3780
module is available from Jaycar stores
for $23.95 or their online Techstore for
$31.95, including delivery.
Because the sensor’s mini six-pin
SIL connector is on the top of the
case, the XC3780 module comes with
a short six-wire cable connecting it to
a matching mini SIL connector on the
end of the module’s PCB. There are
some passive components at the same
end of the board plus a four-pin SIL
header with standard 0.1in/2.54mm
spacing, to simplify connection to an
external MCU.
Fig.8 shows the components inside
the GP2Y1010AU sensor itself, and as
you can see, it’s similar to Fig.5 apart
from not having a microcontroller to
digitise and process the output signal.
In this case, the analog output signal
“VO” is simply made available at pin 5.
Note that the centre amplifier
The Jaycar XC3780 module is based on the Sharp
GP2Y1010AU dust sensor. Being fanless, it relies on air
diffusing through 7.5mm diameter holes in the top and
bottom of the sensor’s case. It has a varying DC voltage
output rather than digital outputs, so conversion into a
dust density figure is done by software running on the
controlling MCU.
siliconchip.com.au
Australia's electronics magazine
November 2022 81
Fig.8: the main difference between this GP2Y1010AU ‘dust’ sensor and the
Panasonic sensor shown in Fig.5 is that this one lacks any digital control
electronics; it only includes analog signal processing. Therefore, the driving
microcontroller module must power the LED via pins 1-3, measure the
voltage at output pin 5 and convert that into a particle level.
Fig.9: this curve shows the transfer function between the output voltage of
the GP2Y1010AU sensor and the corresponding dust density in mg/m3. A
table (or similar) representing the points in this plot needs to be loaded into
the microcontroller to perform this conversion.
Fig.10: there aren’t many components on the Jaycar XC3780 module besides
the Sharp sensor. All they do is filter the power supply to the module,
provide a power-on indication via LED1 and route the necessary signals to a
standard four-pin header for connection to an MCU.
82
Silicon Chip
Australia's electronics magazine
section has a small adjustable resistor or trimpot to adjust the sensor’s
effective sensitivity. But the Sharp
data sheet for the GP2Y1010AU sensor warns that this trimpot is set to
make the sensor conform to its specification before shipment. As a result,
they advise against further adjustment
of the trimpot.
This specification is summarised in
Fig.9, which shows how the output
voltage (VO) varies with dust density.
VO is close to 0.9V with zero dust in
the air, rising relatively linearly to
about 3.25V at a dust density of 0.4mg/
m3 before flattening off at about 3.55V
for a dust density of 0.53mg/m3. It then
rises very slowly to about 3.6V for a
dust density of 0.8mg/m3. Note that
1mg = 1000μg.
The complete circuit of the XC3780
module is shown in Fig.10, and there
are only a few passive components on
the PCB apart from the GP2Y1010AU
sensor itself. The 150W resistor and
220μF capacitor provide decoupling
and smoothing for the supply to the
sensor’s internal LED, while the 1kW
resistor and LED1 indicate when the
module is powered up.
Connecting the XC3780 module to
an Arduino is quite straightforward, as
shown in Fig.11. The GND and VCC
pins of the module can be connected to
the GND and +5V pins of the Arduino.
The LED pin should be connected to
the IO3 (D3) pin of the Arduino while
the VO/OUT pin goes to the Arduino’s
ADC0 (A0) input.
These are the connections needed to
ensure that the XC3780 module works
correctly when a specific sketch runs
on the Arduino. That sketch uses a
particular library to control the LED
inside the GP2Y1010AU and convert
its DC output voltage into the equivalent dust density.
I found this library on the Arduino website in the reference → libraries → sensors section. Called PMsensor, it was written by JongHyun Woo,
and the latest version is 1.1.0. When I
downloaded this library (“PMsensor-
master.zip”) and installed it in my
Arduino IDE, I found that it came with
an example sketch called “PMsensor_
demo.ino”.
This sketch provides almost no
information on the correct connections
for the sensor’s LED and VOUT lines,
or the correct baud rate to use for the
Arduino link back to the PC. However,
after examining the code in the sketch,
siliconchip.com.au
I determined that the proper connections were those shown in Fig.11, and
the correct baud rate was 9600 baud. I
then powered it up and got the result
shown in Fig.12.
I decided to adapt JongHyun Woo’s
sketch into one with more helpful
information in a ‘header’ section. I
called this new sketch “SC_PMsensor_
demo.ino” and it is available to download for free from siliconchip.com.au/
Shop/6/62
As you can see from Fig.12, this
sketch simply pulses the sensor’s internal LED once per second, then reads
its output voltage and converts it into
an equivalent dust density reading.
This is then printed in the lines reading “Filter : XXX.XX”.
You may have noticed in Fig.12 that
at the top of the listing, the readings
are low. But then they started rising
because I struck a match and blew it
out with the smoke passing over the
top of the sensor.
Precisely what these figures mean
is not too clear, though. They could
represent the dust density in μg/m3
(micrograms per cubic metre), or they
might not.
So the XC3780 dust sensor can be
connected fairly easily to an MCU like
an Arduino, and it does work using
JongHyun Woo’s library and demo
sketch. But the accuracy and significance of its readings are a tad indeterminate.
The bottom line
Overall, I prefer the Grove-Laser
module based on the HM3301 fan
sensor. It is the most expensive of the
three, but not unreasonably so, considering its ease of use and the apparent
accuracy of its readings.
I would have to rate the Panasonic
SN-GCJA5 sensor as the next best;
although it seems to give fairly accurate readings, it lacks a fan and also
has the disadvantage of not coming
with a matching cable.
The Jaycar XC3780 module is only
about half the cost of the other two
modules/sensors and is the easiest
to get.
But the fact that it needs software
running in the Arduino to convert its
DC output voltage into dust density
makes me a little less confident in
the accuracy of its readings. Still, it
would be fine if all you needed were
relative readings, eg, to use it as a kind
of smoke alarm.
SC
siliconchip.com.au
Fig.11: connecting the Jaycar
XC3780 module to an MCU is
straightforward. Various pin
connections could be used, but this
is the routing needed for the test
sketch to work. It uses one digital
pin (to control its internal LED)
and one analog pin (for sensing the
output voltage).
Fig.12: XC3780 sample output
15:15:25.825
15:15:25.825
15:15:26.762
15:15:26.809
15:15:26.809
15:15:27.793
15:15:27.840
15:15:27.840
15:15:28.824
15:15:28.824
15:15:28.871
15:15:29.808
15:15:32.854
15:15:32.901
15:15:33.839
15:15:40.962
15:15:40.962
15:15:41.946
->
->
->
->
->
->
->
->
->
->
->
->
->
->
->
->
->
->
Read PM2.5
Filter: 11.15
=========================
Read PM2.5
Filter: 30.79
=========================
Read PM2.5
Filter: 78.10
=========================
Read PM2.5
Filter: 120.76
=========================
Read PM2.5
Filter: 253.01
=========================
Read PM2.5
Filter: 396.47
=========================
We assume the readings are in μg/m3 but the documentation is a bit vague
Useful links
Suppliers:
• www.pakronics.com.au
• https://au.element14.com/3523840
• www.jaycar.com.au
Software libraries:
• www.arduino.cc/reference/en/libraries/grove-laser-pm2.5sensor-hm3301
• https://github.com/Seeed-Studio/Seeed_PM2_5_sensor_HM3301
• www.arduino.cc/reference/en/libraries/pmsensor/
• https://github.com/ekkai/PMsensor
• https://github.com/sparkfun/SparkFun_Particle_Sensor_SN-GCJA5_
Arduino_Library
Panasonic SN-GCJA5 data sheet: siliconchip.au/link/aber
Sharp dust sensor application note: siliconchip.au/link/abeq
Australia's electronics magazine
November 2022 83
|