Labs / Electronic modules

GraftSense: An Air Quality Monitoring Module Based on MEMS Gas Sensors (Open Version)

Author: Li Zisheng · Source: FreakStudio open documentation, v1.5 · License: CC BY 4.0 · Driver code (sensors/mems_driver): MIT License

Contents
4
R12 D1 U7 v1.6 I2C

I. Module Introduction

Based on the MEMS gas sensor-based air quality monitoring module, which adopts I2C communication and is equipped with the PCA9546ADR multiplexer chip, can be connected to 4 types of gas sensors for smoke, carbon monoxide, VOC and formaldehyde. Powered by 5V input which is stepped down to 3.3V and 1.4V to supply power for the sensors and internal heating respectively, it integrates circuits including power filtering, indication and MCU interface, capable of monitoring multiple gases, and is applicable to scenarios related to air quality monitoring.

II. Introduction to Main Chips

An I2C expansion chip PCA9546ADR is used to connect four gas detection sensors respectively, which are smoke sensor (JED115), carbon monoxide sensor (JED104), VOC sensor (JED101) and formaldehyde sensor (JED116).

2.1 Chip Overview

I2C PCA9546ADR 4 1 3 1.8V 5V 40 85
3.3V 0.1VDC 1.4V

2.2 Pin Definition

PCA9546ADR 16 A0 A1 A2 SC0 SC1 SC2 SC3 SD0
PCA9546ADR 16 C1 C2 5.5V DOUT2 DOUT1 232 RIN2 RIN1
PCA9546ADR 1 8 3.3V 1.4V 2 3 7 4 5

2.3 Functional Block Diagram

PCA9546A 14 15 2 13 1 A0 A1 A2

This is the internal functional block diagram of the PCA9546A chip, which is an I²C bus multiplexer designed to expand I²C bus channels. It enables connecting multiple slave devices to a single I²C bus, supporting time-division switching control for multiple I²C devices. The functions of each module are explained as follows:

2.4 Performance Parameters

2.4.1 PCA9546A Performance Parameters

PCA9546A I0 I0C C1 C2 C3 C4 0.81V 0 3.6V

2.4.2 Formaldehyde Sensor (JED116) Performance Parameters

JED116 I2C 25mA 10 100kbps 60S 3.3V 0 100ppm

2.4.3 Smoke Sensor (JED115) Performance Parameters

300 10000ppm 3.3V 25mA 30mW 1.4V I2C 0x54 10-100kbps 30s

2.4.4 Performance Parameters of VOC Sensor (JED101)

JED116 I2C 3.3V 25mA 30mW 1.4V

2.4.5 Carbon Monoxide Sensor (JED104) Performance Parameters

JED116 3.3V 25mA 30mW 1.4V I2C 0x54 10-100kbps 30s 60S

2.5 Reference Circuit

PCA9546A I2C/SMBus 3.3V 2.3V 5.5V 0 3 SD0 SD3 SC0

2.6 Chip Configuration

None.

I2C PCA9546A
I2C 8 5 PCA9546A
8-3 I2C
I2C PCA9546A 1 2 8 9

Data is transmitted to the PCA9546A control register using the write mode shown in Figure 8-5.

PCA9546A 1 0 A2 A1 A0 B3 B2 B1 B0

Use the read mode shown in Figure 8-6 to read data from the PCA9546A control register.

8-6 PCA9546A

Device Address:

PCA9546A 1110 A2 A1 A0 1 0
PCA9546A 8.6.2 8 0 2 3 I2C
PCA9546A B7 B0 0 1 B1 B3

2.8 PCB Routing Precautions

For the PCB layout of the PCA9546A, general PCB layout specifications shall be followed, and additional requirements related to high-speed I²C signals shall also be noted. Common PCB impedance and differential pairs are not a concern at I²C signal speeds. Typically, a dedicated ground plane is arranged in the inner layer of the circuit board, and pins connected to ground must form a low-impedance path to the ground plane by means of wide copper pours and multiple vias.Bypass capacitors and decoupling capacitors are commonly used to control the voltage ripple at the V₍₆₆₎ pin: larger capacitors provide additional power during short-term power supply fluctuations, while smaller capacitors are used to filter out high-frequency ripple.

In applications where voltage conversion is not required, all V₍ₚₙₓ₎ voltages and V₍₆₆₎ can be at the same potential, and a single copper layer can connect all pull-up resistors to the corresponding reference voltage. In applications where voltage conversion is required, V₍ₚᵤₗₗ₋ₚₒₛ₎, V₍ₚᵤₗₗ₋ₙₑ₉₎, V₍ₚᵤₗₗ₋ᵤₚ₎, V₍ₚᵤₗₗ₋ₙₒᵣₘₐₗ₎ and V₍ₚᵤₗ₋ₙₑ₉₎ can all be located on the same copper layer, with split planes isolating different voltage potentials.

To reduce the total capacitance of the I²C bus when adding PCB parasitic capacitance, the data lines (SCN and SDN) must be as short as possible, and the trace width must also be minimized (e. g., 5-10 mils selected according to the copper weight).

PCA9546A VCC1 VCC2 A0 A1 A2 A3 A4

III. Circuit Engineering

3.1 Circuit Source Engineering

To obtain the source code of the circuit, please follow the official account [Freak Embedded]

3.2 Module Usage Instructions

The schematic diagram of this module is shown below:

SCH_Air Quality Monitoring Module Based on MEMS Gas Sensor_v1.6_2026-04-05.pdf 2.6 MB

U1 U2 U3 U4 U5 U6 U7 U8 R1 R2
v1.6 I2C

This module has an I2C communication interface, using an I2C expansion chip PCA9546A can mount four gas sensors smoke sensor ( JED115 ), carbon monoxide sensor ( JED104 ), VOC sensor ( JED101 ) and formaldehyde sensor ( JED116 ), we can use the MCU interface connected to the I2C communication interface for communication, sequentially switching I2C expansion chip PCA9546A different I2C channels and gas sensors for communication.

Please note during use: zero calibration must be performed in advance in the air!!!

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing, and the MEMS gas sensor-based air quality monitoring module uses the I2C interface to communicate with the main controller.

Here, we first use the HY2.0-4P cable to connect the module to the GraftPort-RP2040 development board's I2C0 interface:

GraftPort-RP2040 4 5 HY2.0-4P I2C0

The module connections are shown in the following table:

Development Board Pins

Module Pins

Description

Pin 4

SDA

I2C data transmission line, corresponding to I2C0 's SDA

Pin 5

SCL

I2C clock signal line, corresponding to I2C0 's SCL

Here, we need to search for the relevant driver packages on uPyPI: https://upypi.net/zh/

106 MicroML4

Enter mems_driver to search, and the following will be displayed:

1.0.0 2026 02 12

Click to copy the local installation command:

1.0.0 2024 02 12 upypi.net/pkg/mems_driver/1.0.0

Here, we can import the module driver library code via the mip tool. The usage commands for the mpremote tool are as follows:

mpremote mip install github:FreakStudioCN/GraftSense-Drivers-MicroPython/sensors/mems_driver

Import the air quality monitoring module based on MEMS gas sensor - MicroPython driver code, then copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-
# @Time    : 2025/12/22 PM 2:21
# @Author  : hogeiha
# @File    : main.py
# @Description : MEMS gas sensor multi-channel reading example code, implementing calibration and real-time concentration reading for four gases: VOC/CO/H2S/NO2

# ======================================== Import Modules =========================================

from machine import Pin, SoftI2C
import time
from mems_air_module import MEMSGasSensor, PCA9546ADR, AirQualityMonitor

# ======================================== Initialization ==========================================

# Delay to wait for the device to initialize
time.sleep(3)
# Print debug information
print("FreakStudio : Using IIC to read MEMS sensor")

i2c = SoftI2C(sda=Pin(4), scl=Pin(5), freq=100000)


monitor = AirQualityMonitor(i2c)


# Channel 0: VOC sensor registration and calibration
print("Registering and calibrating VOC sensor on channel 0...")
monitor.register_sensor(0, MEMSGasSensor.TYPE_VOC)
monitor.calibrate_sensor(MEMSGasSensor.TYPE_VOC)

# Channel 1: CO sensor registration and calibration
print("Registering and calibrating CO sensor on channel 1...")
monitor.register_sensor(1, MEMSGasSensor.TYPE_CO)
monitor.calibrate_sensor(MEMSGasSensor.TYPE_CO)

# Channel 2: H2S sensor registration and calibration
print("Registering and calibrating H2S sensor on channel 2...")
monitor.register_sensor(2, MEMSGasSensor.TYPE_H2S)
monitor.calibrate_sensor(MEMSGasSensor.TYPE_H2S)

# Channel 3: NO2 sensor registration and calibration
print("Registering and calibrating NO2 sensor on channel 3...")
monitor.register_sensor(3, MEMSGasSensor.TYPE_NO2)
monitor.calibrate_sensor(MEMSGasSensor.TYPE_NO2)

# ======================================== Main Program =============================

print("\nStart reading gas concentration (press Ctrl+C to stop)...")
print("-" * 50)

while True:
    try:
        # Read the concentration values of all registered sensors and return a {sensor type: concentration} dictionary
        results = monitor.read_all()

        # Print the formatted gas concentration values
        print(f"VOC concentration: {results[MEMSGasSensor.TYPE_VOC]}")
        print(f"CO concentration: {results[MEMSGasSensor.TYPE_CO]}")
        print(f"H2S concentration: {results[MEMSGasSensor.TYPE_H2S]}")
        print(f"NO2 concentration: {results[MEMSGasSensor.TYPE_NO2]}")
        print("-" * 50)

    except Exception as e:
        # Catch and print all exceptions to avoid program crashes
        print(f"Error reading concentration: {str(e)}")
        print("-" * 50)

    # Read data once every 1 second
    time.sleep(1)

When flashing the code, the terminal output is as follows:

H2S NO2 0 3 610 589

IV. Drivers

mems_driver-1.0.1.zip 13 KB

None.

VI. Revision History

Document Version

Date Modified

Modifier

Modify Content

v1.0

2025-10-24

Ling Gaoxing

Initialize the document

v1.1

2025-12-29

Li Zisheng

Added application experiments and production files

v1.2

2026-03-29

Xin Ruili

Modified the application experiment section

v1.3

2026-04-05

Li Zisheng

Update the circuit engineering to v1.6,

The cover photo has not been taken, the production files have not been exported yet, and all other items have been sorted out.

v1.4

2026-04-21

Li Zisheng

The production documents have not been exported yet, and all the rest have been sorted out.

v1.5

2026-04-29

Xin Ruili

Create an open version of the document based on the internal document version v1.4.

7. Relevant Materials

7.1 Chip Datasheet

MEMS Digital Design Guide.doc 671 KB

MEMS Digital Smoke Sensor JED115-001.docx 452 KB

I2C Multiplexer_PCA9546ADR(UMW)_Datasheet_UMW+PCA9546.PDF 1.7 MB

MEMS Digital CO Sensor JED104-001.docx 452 KB

MEMS Digital VOC Sensor JED101-001.docx 452 KB

MEMS Digital Formaldehyde Sensor JED116-001.docx 452 KB

7.2 Unique Icons for PCB Silk Screen

GraftSense: An Air Quality Monitoring Module Based on MEMS Gas Sensors (Open Version)