PM2.5 Module
PM2.5 Air Quality Module is an ambient air quality testing Module. This product adopts PMSA003 digital universal particulate matter concentration sensor. It can quickly collect and calculate the number of suspended particles of different particle sizes in the air per unit volume.
The other two versions come with the STH30 and SHT20, which can be used to measure ambient temperature and humidity.
Support the following products:
Micropython Example:
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from module import PM25Module 9import time 10 11 12title0 = None 13label9 = None 14label0 = None 15label10 = None 16label1 = None 17label2 = None 18label3 = None 19label4 = None 20label5 = None 21label6 = None 22label7 = None 23label8 = None 24pm25_0 = None 25 26 27def setup(): 28 global \ 29 title0, \ 30 label9, \ 31 label0, \ 32 label10, \ 33 label1, \ 34 label2, \ 35 label3, \ 36 label4, \ 37 label5, \ 38 label6, \ 39 label7, \ 40 label8, \ 41 pm25_0 42 43 M5.begin() 44 Widgets.fillScreen(0x222222) 45 title0 = Widgets.Title("PM2.5 Module Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18) 46 label9 = Widgets.Label("Temp:", 191, 26, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 47 label0 = Widgets.Label("PM1.0 Env:", 1, 26, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 48 label10 = Widgets.Label("Humi:", 191, 52, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 49 label1 = Widgets.Label("PM2.5 Env:", 1, 52, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 50 label2 = Widgets.Label("PM10 Env:", 1, 77, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 51 label3 = Widgets.Label( 52 "Particles 0.3um:", 1, 100, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18 53 ) 54 label4 = Widgets.Label( 55 "Particles 0.5um:", 1, 124, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18 56 ) 57 label5 = Widgets.Label( 58 "Particles 1.0um:", 1, 145, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18 59 ) 60 label6 = Widgets.Label( 61 "Particles 2.5um:", 1, 167, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18 62 ) 63 label7 = Widgets.Label( 64 "Particles 5um:", 1, 189, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18 65 ) 66 label8 = Widgets.Label( 67 "Particles 10um:", 1, 210, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18 68 ) 69 70 pm25_0 = PM25Module(2) 71 pm25_0.set_module_mode(0) 72 pm25_0.set_module_power(True) 73 print(pm25_0.get_module_power()) 74 75 76def loop(): 77 global \ 78 title0, \ 79 label9, \ 80 label0, \ 81 label10, \ 82 label1, \ 83 label2, \ 84 label3, \ 85 label4, \ 86 label5, \ 87 label6, \ 88 label7, \ 89 label8, \ 90 pm25_0 91 M5.update() 92 pm25_0.request_air_data() 93 pm25_0.refresh_data() 94 label0.setText(str((str("PM1.0 Env:") + str((pm25_0.get_pm_data(3)))))) 95 label1.setText(str((str("PM2.5 Env:") + str((pm25_0.get_pm_data(4)))))) 96 label2.setText(str((str("PM10 Env:") + str((pm25_0.get_pm_data(5)))))) 97 label3.setText(str((str("Particles 0.3um:") + str((pm25_0.get_pm_data(6)))))) 98 label4.setText(str((str("Particles 0.5um:") + str((pm25_0.get_pm_data(7)))))) 99 label5.setText(str((str("Particles 1.0um:") + str((pm25_0.get_pm_data(8)))))) 100 label6.setText(str((str("Particles 2.5um:") + str((pm25_0.get_pm_data(9)))))) 101 label7.setText(str((str("Particles 5um:") + str((pm25_0.get_pm_data(10)))))) 102 label8.setText(str((str("Particles 10um:") + str((pm25_0.get_pm_data(11)))))) 103 label9.setText(str((str("Temp:") + str((pm25_0.get_temperature()))))) 104 label10.setText(str((str("Humi:") + str((pm25_0.get_humidity()))))) 105 time.sleep_ms(100) 106 107 108if __name__ == "__main__": 109 try: 110 setup() 111 while True: 112 loop() 113 except (Exception, KeyboardInterrupt) as e: 114 try: 115 from utility import print_error_msg 116 117 print_error_msg(e) 118 except ImportError: 119 print("please update to latest firmware")
UIFLOW2 Example:
class PM25Module
Constructors
- class PM25Module
Init Module PM2.5 with UART.
UIFLOW2:
Methods
- PM25Module.set_module_power(state)
Set the PM25Module power state.
- Parameters:
state – Set to True to enable power, False to disable.
UIFLOW2:
- PM25Module.get_module_power() bool
Get the PM25Module power state.
- Parameters:
state – Get the module power state.
UIFLOW2:
- PM25Module.set_module_mode(mode)
Set the PM25Module work mode.
- Parameters:
mode –
Options:
Active mode
: 1Passive mode
: 0
UIFLOW2:
- PM25Module.refresh_data()
Refresh the PM25Module data.
- Parameters:
mode –
Options:
Active mode
: 1Passive mode
: 0
UIFLOW2:
- PM25Module.request_air_data()
Request PM25Module air data.
UIFLOW2:
- PM25Module.get_pm_data(data_num)
Select the type of particulate matter data to retrieve.
- Parameters:
data_num (int) –
The options range from standard PM concentrations to counts of particles of specific sizes in 0.1 liters of air.
Options:
PM1.0 Concentration(Std)
: 0PM2.5 Concentration(Std)
: 1PM10 Concentration(Std)
: 2PM1.0 Concentration(Env)
: 3PM2.5 Concentration(Env)
: 4PM10 Concentration(Env)
: 5Particels more than 0.3um in 0.1 liters of air
: 6Particels more than 0.5um in 0.1 liters of air
: 7Particels more than 1.0um in 0.1 liters of air
: 8Particels more than 2.5um in 0.1 liters of air
: 9Particels more than 5.0um in 0.1 liters of air
: 10Particels more than 10um in 0.1 liters of air
: 11
UIFLOW2:
- PM25Module.get_temperature()
Get PM25Module environmental temperature data.
UIFLOW2:
- PM25Module.get_humidity()
Get PM25Module environmental humidity data.
UIFLOW2: