{"id":13802412,"url":"https://github.com/pkucmus/micropython-pms7003","last_synced_at":"2025-06-29T01:08:05.586Z","repository":{"id":45565816,"uuid":"134145150","full_name":"pkucmus/micropython-pms7003","owner":"pkucmus","description":"Micropython driver for the PMS7003 Air Quality Sensor","archived":false,"fork":false,"pushed_at":"2021-12-08T09:10:12.000Z","size":20,"stargazers_count":34,"open_issues_count":0,"forks_count":11,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-28T17:51:50.132Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pkucmus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-20T11:37:16.000Z","updated_at":"2025-04-13T08:54:55.000Z","dependencies_parsed_at":"2022-08-28T07:11:59.902Z","dependency_job_id":null,"html_url":"https://github.com/pkucmus/micropython-pms7003","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pkucmus/micropython-pms7003","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkucmus%2Fmicropython-pms7003","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkucmus%2Fmicropython-pms7003/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkucmus%2Fmicropython-pms7003/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkucmus%2Fmicropython-pms7003/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkucmus","download_url":"https://codeload.github.com/pkucmus/micropython-pms7003/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkucmus%2Fmicropython-pms7003/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262518514,"owners_count":23323341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:43.897Z","updated_at":"2025-06-29T01:08:05.561Z","avatar_url":"https://github.com/pkucmus.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Sensors"],"readme":"# PMS7003 MicroPython Driver\n\nThis is a MicroPython adaptation inspired by this Raspberry implementation: https://www.raspberrypi.org/forums/viewtopic.php?p=1244895\u0026sid=5f9dab0e19a7086f9b900b51316ff349#p1244895\n\n[Here](https://botland.com.pl/index.php?controller=attachment\u0026id_attachment=2182) you can find the data sheet from [botland.com.pl](https://botland.com.pl/czujniki-czystosci-powietrza/10924-czujnik-pylu-czystosci-powietrza-pms7003-33v-uart.html)\n\n## Caveats\n\n### UART\nI used it with an ESP32. Tried with ESP8266 but since it has only one (full)UART that is being used by the REPL (and WebREPL) it was unusable. ESP32 has an unused UART (UART 2) that can be used to communicate with other devices. So you need a chip that has a free UART (like ESP32).\n\n### Voltage\nThe documentation claims that the device needs to run on 5V as it's internal fan is driven by 5V where the data pins output 3.3V for high.\n**This was not the case for me** I could not read any data other than zeros from the UART when running on 5V.\nPowering the whole device with 3.3V works fine (even though the fan may spin with slower).\nI tested running on 3.3V on six different PMS7003 devices.\n[MicroPython forum link where I asked for help](https://forum.micropython.org/viewtopic.php?t=4566)\n\n## Example usage\n\n    from pms7003 import Pms7003\n\n    pms = Pms7003(uart=2)\n    pms_data = pms.read()\n\n`Pms7003.read()` will return a dictionary with *the oldest* read that is in the buffer. It means that your reads will always be a bit off in time, depending on the UART's buffer size and the frequency of your reads.\nIt's generaly a good idea not to read faster than the device writes.\n\nThe dictionary will contain the following data:\n\nKey         | Description |                                               \n:-----------|:------------------------------------------------------------\nPM1_0       | PM 1.0 concentration μ g/m3 (factory environment)           \nPM2_5       | PM 2.5 concentration μ g/m3 (factory environment)           \nPM10_0      | PM 10 concentration μ g/m3 (factory environment)            \nPM1_0_ATM   | PM 1.0 concentration μ g/m3 (atmospheric environment)       \nPM2_5_ATM   | PM 2.5 concentration μ g/m3 (atmospheric environment)       \nPM10_0_ATM  | PM 10 concentration μ g/m3 (atmospheric environment)        \nPCNT_0_3    | Particle count of diameter beyond 0.3 um in 0.1 liter or air\nPCNT_0_5    | Particle count of diameter beyond 0.5 um in 0.1 liter or air\nPCNT_1_0    | Particle count of diameter beyond 1.0 um in 0.1 liter or air\nPCNT_2_5    | Particle count of diameter beyond 2.5 um in 0.1 liter or air\nPCNT_5_0    | Particle count of diameter beyond 5.0 um in 0.1 liter or air\nPCNT_10_0   | Particle count of diameter beyond 10 um in 0.1 liter or air\n\n(and four more with `FRAME_LENGTH`, `VERSION`, `ERROR` and `CHECKSUM`)\n\n# Passive Driver\n\nPMS7003 can work also in passive mode. It means that user has to request data\nexplicitly by sending a command message with appropriate data.\nMore about this [article](https://joshefin.xyz/air-quality-with-raspberrypi-pms7003-and-java/).\nDetails are in [datasheet](https://www.espruino.com/datasheets/PMS7003.pdf) as well.\n\n```python\nimport micropython\nfrom pms7003 import PassivePms7003\n\npms = PassivePms7003(uart=2)\n\ndef do_work(__):\n    pms.wakeup()\n    \n    pms_data = pms.read()\n    print(pms_data)\n    \n    pms.sleep()\n\n# usually performing readings in interrupt handler (e.g. Timer's)\n# so use schedule to avoid heap lock limitations:\n# https://docs.micropython.org/en/latest/reference/isr_rules.html\ncallback = lambda __: micropython.schedule(do_work, 0)\n```\n\n# AQI\n\nThis repo also contains a simple class that can help calculate the Air Quality Index (as described [here](https://en.wikipedia.org/wiki/Air_quality_index#Computing_the_AQI))\n\n```python\nfrom pms7003 import Pms7003\nfrom aqi import AQI\n\npms = Pms7003(uart=2)\npms_data = pms.read()\naqi = AQI.aqi(pms_data['PM2_5_ATM'], pms_data['PM10_0_ATM'])\n```\n\n`AQI.aqi(pm2_5_atm, pm10_0_atm)` returns an integer representing the AQI.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkucmus%2Fmicropython-pms7003","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkucmus%2Fmicropython-pms7003","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkucmus%2Fmicropython-pms7003/lists"}