Xiaomi Mijia Air Quality Tester for your Smart Home

Air Quality Measurement Featured Image

The Mijia air quality tester in your home is important for your health. There are a lot of products improve it, starting with HEPA filters like the Alfawise P1 which we reviewed a while ago. To measure factors like temperature and humidity in your house there are lot of affordable options. To measure the other factors that determine air quality there are less products, and when you find them they are often more expensive. But there are options! In this article we will talk about a plug-and-play and also standalone Xiaomi product. The Xiaomi Mijia Air Quality Detector (model number KQJCY02QP). So If you want to improve your indoor air quality you first have to measure, but this device is also very nice if you like data (it handles: PM2.5, T∨OC, COa, temperature and humidity) and gadgets 🙂

The picture below is from co2.earth and shows the part per million (ppm) that it is normal now. You can see that our co2 level is rising quite fast! But what’s normal? The xiaomi air quality tester should always display above the number below.

CO2 Past.  CO2 Present.  CO2 Future.



Xiaomi has a lot of affordable smart home devices and now they have also a (new) CO2 meter. With build in battery and tft touchscreen. Therefore it can be used stand alone, but we want to include it also with the mi home app and integrated in your own smart platform like Domoticz or Home Assistant.

Main Features

  • Desktop handheld can be used as a stand alone device
  • Remote monitoring, view home air quality anytime, anywhere with the mi home app.
  • Built-in Bluetooth Gateway function (works with mi flora for example)
  • Power connector: USB Type-C
  • Support system: Android 4.3, or iOS9.0 and above
  • Wireless connection: WiFi IEEE 802.11b/g/n 2.4GHz

Specifications of the Mijia Air Quality Tester

  • Product size: 109 × 64 × 29.5mm
  • Product net weight: 182g
  • Battery type: lithium ion battery
  • Input parameters: 5VE: 1A
  • Power connector: USB Type-C
  • Support system: Android43 or S90 and above
  • Wireless connection: Vi-Fi IEEE 802.11b/g/n 2. 4GHZ
  • Screen size: 3.97 inches
  • Screen resolution: 800 × 480p

Package Contents

  • Air Monitor
  • USB Charging Cable
  • Chinese Manual

Official Mi Home Mobile apps

The Mi Home App can be used for remote monitoring and connecting the device to your smart home system, so that the Air Quality Tester becomes an extension. The Mi Home apps be downloaded from the following places:

Setup the Xiaomi Air quality tester

Setup the Xiaomi MiJia Air Quality Detector KQJCY02QP is very easy:

Testing the Xiaomi air quality tester

First, we take a closer look to the hardware.
The device has an sensor for changing orientation: landscape of portrait. It looks like it’s designed for landscape because the holes are on the sides and the USB connector is also in landscape.The device are operating the whole day with screen on brightest and it would not warm.
The air quality tester has a simple but effective design. It’s robuust and has rubber on the bottom so it can’t slide from the table.

Next it is time to speak about the software side.
Default language on the device is chinese, but luckily this can be changed to english.
Wifi is only 2.4ghz and the typing the password to connect to your Wifi is very easy.
The screen is responsive and typing is like an Android telephone.
When you would use this device in mi-home, choose Mainland China. It’s not designed for Europe, and when writing this article it’s not visible in europe. So set you mi-home app> settings> region > mainland china.
Weather: It can show weather info but in my situation it did not work because i’m not in China.
Data is everything 🙂 and the app is really handy to show graphs with historical data.

Xiaomi integrated in your smart home

Xiaomi products like for example the air quality testers, vacuums, air purifiers all communicate with the gateway in a secure way, they therefore require a token. So if you want to use a device in other software than Mi Home you need to obtain the token. Retrieving the token can be difficult. We link to https://github.com/jghaanstra/com.xiaomi-miio/blob/master/docs/obtain_token.md and https://www.home-assistant.io/integrations/vacuum.xiaomi_miio/#retrieving-the-access-token because they have several methods and keep them actual.

I retrieved my token with the old Android version of Mi Home method.

Xiaomi Air quality tester into Hass.io

When I wrote this article native integration was not yet possible. We linked to the russian tutorial for hass on linux to help at least some readers. But on facebook people showed me the link: https://www.home-assistant.io/integrations/air_quality.xiaomi_miio/. But this means native integration if you are running version 0.102. Therefore, you only need to have your token and the right IP.

Adding the xiaomi air quality tester is very simple:
Add it into the mi-home app, retrieve token and add it to you configuration:

# Example configuration.yaml entry
  - platform: xiaomi_miio
    host: IP_ADDRESS
    token: YOUR_TOKEN

Xiaomi Air quality tester into home assistant

We found an interesting tutorial written in russian to get it work. And it works! So here is a video to get the Xiaomi MiJia Air Quality Detector (KQJCY02QP) working in home assistant:

And the text version of it: https://telegra.ph/Dobavlenie-Xiaomi-Mijia-Air-Detector-v-Home-Assistant-08-26. All credits goes to this russian guy who wrote it for the telegram group: @configit

Total Time: 5 minutes

Install php

apt-get install php

Clone repository and get the latest files

Check connection and get device info

php miio-cli.php –ip IP_УСТРОЙСТВА –token ТОКЕН –info

create script file and save it as: air_tester.sh

id=$(echo $RANDOM % 1000 + 1 | bc)
php miio-cli.php –ip YOURIP –token YOURТОКЕN –sendcmd ‘{“id”:'”$id”‘,”method”:”get_air_data“,”params”:[]}’ | tail -1 | sed ‘s/{“result”://g’ | sed ‘s/\,”id.*//g’

Give this file execution permissions

chmod +x air_tester.sh

test created script file

./air_tester.sh and check the output.

Create sensors in Home-assistant config

– platform: command_line
  name: Air Tester
   command: ‘/home/your_user/scripts/air_tester.sh’
   value_template: “{{ value_json[‘co2e’][‘pm25’][‘humidity’][‘temperature’][‘tvoc’] }}”
    – co2e
    – pm25
    – humidity
    – temperature
    – tvoc
   scan_interval: 30

  – platform: template
     friendly_name: “CO2a”
     unit_of_measurement: “ppm”
     value_template: “{{ states.sensor.air_tester.attributes.co2e }}”
  – platform: template
     friendly_name: “TVOC”
     unit_of_measurement: “mg/m3”
     value_template: “{{ ( states.sensor.air_tester.attributes.tvoc | round(2)) }}”
  – platform: template
     friendly_name: “PM 2.5”
     unit_of_measurement: “ppm”
     value_template: “{{ ( states.sensor.air_tester.attributes.pm25 | round(1))}}”
  – platform: template
     friendly_name: “Humidity”
     unit_of_measurement: “%”
     value_template: “{{ ( states.sensor.air_tester.attributes.humidity | round(1))}}”
– platform: template
     friendly_name: “Temp”
     unit_of_measurement: “°C”
     value_template: “{{ ( states.sensor.air_tester.attributes.temperature | round(1))}}”

Xiaomi into Domoticz

There is no official support yet for the Xiaomi MiJia Air Quality Detector (KQJCY02QP). But the method for Home Assistant in russian can be modified to get it working in domoticz. php-miio will work on your domoticz linux installation. So the bash file can be modified to push that data to the IDX of a virtual Domoticz dummy sensor. Another option is to modify a python plugin that is available for the older version of the xiaomi air quality tester.
When I found a easy way I will update this article.


It’s nice to have the air quality data into your home automation platform. But that’s not the goal. But we want to do something with that data! So what can be achieved with this data?

  • Control your mechanical ventilation based on this data
  • Control airco or purifiers
  • Check presence of humans in the room
  • Open windows automatically
  • Alerts to change something

Xiaomi MiJia Air Quality Detector (KQJCY02QP) VS DIY alternative

Product Features Overall Price Buy Now
Xiaomi Air Quality

Xiaomi Mijia Air Quality Tester

  • Design
  • Quality
  • Usability
  • Home-Automation compatibility
  • Price
MH-Z19 sensor 0-5000PPM Infrared CO2 Sensor.png

MH-Z19 0-5000PPM Infrared CO2 Sensor For CO2 Indoor Air Quality Monitor UART/PWM

  • Design
  • Quality
  • Usability
  • Home-Automation compatibility
  • Price


We think it’s clear that the Xiaomi MiJia Air Quality Detector (KQJCY02QP) is an easy option for most of the reeders. It has more sensors and a nicer design then the DIY sensor. But Xiaomi could improve the software with other language and weather info for outside China. Also, adding the Xiaomi sensor data into Domoticz or Home Assistant can be hard!

Xiaomi Mija Air Detector Air Quality Monitor
Xiaomi Air Quality

Product Name: Xiaomi Mija Air Detector Air Quality Monitor

Product Description: Measure the indoor air quality with the Xiaomi Mija Air Detector Air Quality Monitor (KQJCY02QP). It does TVOC, CO2, PM2.5, Temperature and Humidity Measurement.

Brand: Xiaomi


Offer price: 72

Currency: Euro

Availability: InStock

Offer URL: https://www.banggood.com/nl/Xiaomi-Mijia-Air-Quality-Tester-High-precision-Sensing-3_97-inch-Screen-Resolution-800480-USB-Inter-p-1381312.html?p=OD1302964369201412GS

  • Design
  • Quality
  • Usability
  • Home-Automation compatibility
  • Price


We think it’s clear that the Xiaomi MiJia Air Quality Detector (KQJCY02QP) is an easy option for most of the reeders. It has lots of sensors (TVOC, CO2, PM2.5, Temperature and Humidity Measurement.) and an Apple stylish design. Xiaomi could improve the software with other languages and weather info for people outside China.
Adding the Xiaomi sensor data into Domoticz or Home Assistant can be hard!


  • Affordable
  • Real Time data (accurate)
  • Clear display
  • Also in English
  • plug and play


  • it can be hard to obtain the token.
  • you need to put some effort into it to get it working into Home Assistant or Domoticz.

Where to buy?