Silicon ChipPAS CO2 Air Quality Sensor Module - August 2023 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions
  5. Back Issues: Hare & Forbes Machineryhouse
  6. Publisher's Letter: Interested in robots?
  7. Feature: How long until we’re all out of work? by Max the Magnificent
  8. Feature: The Fox Report by Barry Fox
  9. Feature: Net Work by Alan Winstanley
  10. Project: Wide-Range OhmMeter by Phil Prosser
  11. Project: 0-110dB RF Attenuator for Signal Generators by Charles Kosina
  12. Project: SPY-DER A 3D-PRINTED DIY ROBOT by Arijit Das
  13. Project: Universal Battery Charge Controller by John Clarke
  14. Feature: PAS CO2 Air Quality Sensor Module by Jim Rowe
  15. Feature: Circuit Surgery by Ian Bell
  16. Feature: Max’s Cool Beans by Max the Magnificent
  17. Feature: AUDIO OUT by Jake Rothman
  18. Feature: Make it with Micromite by Phil Boyce
  19. PCB Order Form
  20. Advertising Index

This is only a preview of the August 2023 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Using Cheap Asian Electronic Modules By Jim Rowe PAS CO2 Air Quality Sensor Module Continuing our series of articles describing low-cost air quality sensors (LCAQS), this month, we take a close look at a sensor module based on photo-acoustic spectroscopy, or PAS for short. This time it’s the Infineon XENSIV PAS CO2 mini-board. S ensors that make use of PAS (photo-acoustic spectroscopy) take advantage of the way molecules of a particular gas absorb specific IR wavelengths according to the Beer-Lambert law. In PAS sensors, the degree of absorption is measured using a phenomenon Alexander Graham Bell discovered in 1880. When a thin metal disc is exposed to pulses of sunlight (Bell used a rotating slotted wheel), it emits sound. Later, Bell showed that materials exposed to the non-visible wavelengths in sunlight (like infra-red/IR and ultraviolet/UV) also emit sound. The basic structure of a PAS sensor is shown in Fig.1. On the left is the pulsed IR light source (generally, an array of LEDs), with an optical filter passing only the wavelengths absorbed by the gas to be detected – in this example, 4.2μm for the detection of CO2. At the far end of the chamber, there is a MEMS microphone optimised to detect low audio frequencies. When the detected sound level is amplified, it can be converted into a figure corresponding to the amount of CO2 present in the cell. The whole sensor is enclosed in an acoustic insulation layer, to reduce the influence of external sound. LCAQS sensors using the PAS principle have only appeared in the last couple of years because their development has depended on MEMS technology. The only one currently available seems to be the XENSIV PAS CO2 sensor from Infineon Technologies (an offshoot of Siemens in Munich, Germany). This comes on a very compact module measuring only 14 x 13.8 x 7.5mm, combining the PAS sensor with a dedicated microcontroller unit (MCU) running advanced compensation algorithms and providing a choice of three different data interface ports. It is currently available from suppliers like Farnell/element14 or DigiKey for around £20-£25. Fig.1: the basic structure of a PAS sensor. A pulsed IR LED emits light through a filter leaving only wavelengths of light that the gas to be detected can absorb. A MEMS microphone then detects low-frequency audio that is emitted by the gas, which can be measured to provide the amount of gas in the cell. Practical Electronics | August | 2023 Inside the module Fig.2 shows a functional block diagram of the XENSIV PAS CO2 sensor module. At the top is the PAS measurement cell, with its gas inlet pipe on the right, the MEMS IR emitter in the centre and the MEMS LF microphone on the left. In the lower part of the diagram are the microcontroller and memory, the light-source driver and the circuit that measures the voltage of the external 12V DC supply that is used to power the IR emitter. As mentioned above, the PAS CO2 sensor mini-board provides a choice of three different data interfaces for communicating with an external MCU: I2C, asynchronous serial (UART) and PWM (pulse-width modulation). The one to be used is chosen by setting the logic level on the PSEL and PWM_DIS control pins. To use the I2C interface, the PWM_ DIS and PSEL pins must be pulled down to GND. For the UART interface, Labels for the pin connections are available on the module underside. 41 Fig.2: a functional block diagram of the XENSIV PAS sensor module. PWM_DIS is pulled down while PSEL is pulled up to logic high (3.3V) instead. Finally, if you want to use the PWM interface, the PWM_DIS pin is pulled to logic high (3.3V). When the I2C interface is selected, the SDA/TX pin is used for the data line and the SCL pin for the clock line. When using this interface, both the SDA/TX and SCL pins need to be fitted with 10kW pull-up resistors to the +3.3V supply. When the UART interface is selected, the SDA/TX line is used as the serial data output and the RX pin for serial data input. But when the PWM interface is selected, the width-modulated pulses emerge from the PWM pin. The INT pin is an output to allow the internal MCU to indicate when it has finished a measurement. I could not find much information on this item, but I suspect that it is only functional when the UART or PWM interfaces are being used. The actual pin connections for the PAS CO2 mini-board are shown in Fig.3, which is a simplified top view of the module. There are six pins on each side, but the two lowest pins, labelled SWD and SWCLK, are for testing during manufacture and should not be connected when the module is being used. All of the remaining pins correspond to those shown in Fig.2. Trying it out Once I had obtained a sample XENSIV PAS CO2 mini-board module, the challenge was to discover how to connect it to a standard low-cost MCU like an Arduino Uno. Fortunately, I found this information on the Infineon website. Although Infineon only provides specific information on connecting the module to either a PSoC 6 WiFi-BT Pioneer Kit or an up-market Arduino Due, I was able to glean enough from the latter option to work out how to connect it to an Uno or similar. This turned out to be relatively straightforward, as you can see from Fig.3, which shows how to connect the module to an Arduino Uno via I2C. The 3.3V logic supply comes from the +3.3V output of the Uno, while the SCL and TX/SDA pins connect to the Uno’s SCL and SDA pins and a pair of 10kW pull-up resistors. The PWM_DIS and PSEL pins are tied to ground for I2C mode, as mentioned earlier. Since the module also needs a 12V DC supply to provide power for the IR LED, this can come from a separate plugpack supply. It can be a small supply, since the average current is less than 600μA with brief pulses of around 20mA. Three bypass capacitors on the 12V supply line provide smoothing. Of course, we need a software library to send commands to and receive data from the sensor, plus a sketch to use the library. After a bit of searching on the Arduino website in the ‘reference/en/ libraries’ section and then in the list of 900-odd contributed libraries for communicating with sensors, I found one called ‘PAS CO2 Arduino Library v1.0.3’. When I clicked on that one, it took me to github.com, where I discovered that the library was provided by and maintained by Infineon! So it was obviously the right one to download. Fig.3: connecting the PAS sensor to an Arduino board is straightforward. Note: we tied the PWM_DIS and PSEL pins to GND so that the module is in I2C mode. Useful links Reproduced by arrangement with PAS modules: SILICON CHIP magazine 2023. • https://bit.ly/pe-aug23-pas1 www.siliconchip.com.au • https://bit.ly/pe-aug23-pas2 • https://bit.ly/pe-aug23-pas3 Software libraries (or download through the Arduino IDE Library Manager): • https://bit.ly/pe-aug23-pas-sw1 • https://reference.arduino.cc/reference/en/libraries/xensiv-pas-co2/ Photoacoustic spectroscopy: • https://w.wiki/4wsX 42 Practical Electronics | August | 2023 I downloaded the library zip file and added it to my Arduino IDE’s list of installed libraries. I then discovered that it came with 12 example sketches – four of which are for using the module’s PWM interface mode, while the other eight are for the serial interface modes (ie, I2C or UART). The latter had the following titles: • serial-alarm • serial-api-test • serial-calibrate • serial-device-id • serial-diagnosis • serial-oneshot • serial-periodic • serial-reset Fig.4: sample output 15:37:04.303 -> pas co2 serial intialized 15:37:09.505 -> co2 ppm value : 633 15:37:14.520 -> co2 ppm value : 623 15:37:19.487 -> co2 ppm value : 621 15:37:24.502 -> co2 ppm value : 611 15:37:29.516 -> co2 ppm value : 609 15:37:34.483 -> co2 ppm value : 610 15:37:39.498 -> co2 ppm value : 649 15:37:44.466 -> co2 ppm value : 1018 15:37:49.480 -> co2 ppm value : 1255 15:37:54.448 -> co2 ppm value : 1254 15:37:59.462 -> co2 ppm value : 1256 15:38:04.477 -> co2 ppm value : 1317 15:38:09.444 -> co2 ppm value : 1409 15:38:14.459 -> co2 ppm value : 1418 15:38:19.426 -> co2 ppm value : 1405 15:38:24.441 -> co2 ppm value : 1392 I decided to try serial-oneshot.ino, and when I loaded it, compiled it and then uploaded it to the Arduino and opened virtual serial port COM3, it all sprang into life. Fig.4 shows the output in the Arduino IDE Serial Monitor following the startup of the serial-oneshot sketch. The first line indicates that the PAS CO2 and its I2C serial port have been initialised, while the following lines show the measured CO2 levels in ppm (parts per million). These measurements are about five seconds apart, as you can see from the timestamps. The other thing to note from Fig.4 is that the initial seven readings are all between 610ppm and 649ppm, whereas the eighth reading suddenly jumps up to 1018ppm and then following readings move up to 1418ppm before starting to fall again. At about 15:37:40, I exhaled towards the PAS CO2 sensor. So it was responding to the sudden increase in CO2 level, as it’s supposed to. Encouraged by this initial success, I then tried loading, uploading and running the serial-calibrate.ino example sketch. This sketch ran very quickly, simply giving a ‘sensor now calibrated’ message before ending. Summary Despite being very compact, the Infineon XENSIV PAS CO2 sensor mini-board is a good performer. As it uses a standard I2C interface, it is compatible with just about any microcontroller, including virtually all Arduinos. No doubt it would work with a Micromite as long as it was set up to send the correct I2C commands. Although it is priced higher than the MOS sensors we’ve looked at previously, and it needs a 12V supply, it is a good choice if you want a small and accurate CO2 sensor. Your best bet since MAPLIN Chock-a-Block with Stock Visit: www.cricklewoodelectronics.com Or phone our friendly knowledgeable staff on 020 8452 0161 Components • Audio • Video • Connectors • Cables Arduino • Test Equipment etc, etc Visit our Shop, Call or Buy online at: www.cricklewoodelectronics.com The PAS sensor measures 14 x 13.8mm, making it tiny in comparison to the enlarged photo shown here. Practical Electronics | August | 2023 020 8452 0161 Visit our shop at: 40-42 Cricklewood Broadway London NW2 3ET 43