{"id":26346815,"url":"https://github.com/styropyr0/mpm10","last_synced_at":"2025-10-05T16:27:15.492Z","repository":{"id":282641968,"uuid":"949225798","full_name":"styropyr0/MPM10","owner":"styropyr0","description":"Driver for MPM10 series PM sensor modules. Supports both I2C and UART for communication.","archived":false,"fork":false,"pushed_at":"2025-03-25T18:22:25.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T18:42:04.096Z","etag":null,"topics":["arduino","arduino-library","esp","esp-library","esp32","esp8266","mpm10","pm-sensor","pm-sensor-lib","sensor-library"],"latest_commit_sha":null,"homepage":"","language":"C++","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/styropyr0.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-16T00:32:17.000Z","updated_at":"2025-03-25T18:20:29.000Z","dependencies_parsed_at":"2025-03-16T01:24:13.931Z","dependency_job_id":"360a69fa-4be4-4e02-894b-9270025308d2","html_url":"https://github.com/styropyr0/MPM10","commit_stats":null,"previous_names":["styropyr0/mpm10"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/styropyr0/MPM10","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FMPM10","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FMPM10/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FMPM10/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FMPM10/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/styropyr0","download_url":"https://codeload.github.com/styropyr0/MPM10/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styropyr0%2FMPM10/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264892413,"owners_count":23679287,"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":["arduino","arduino-library","esp","esp-library","esp32","esp8266","mpm10","pm-sensor","pm-sensor-lib","sensor-library"],"created_at":"2025-03-16T07:14:23.213Z","updated_at":"2025-10-05T16:27:15.389Z","avatar_url":"https://github.com/styropyr0.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MPM10 Particulate Matter Sensor Library for Arduino\n\nThe `MPM10` driver is a C++ library designed to interface with the MPM10 particulate matter sensor. This library supports both UART and I2C communication modes, providing an easy-to-use API to read particulate matter data (PM1.0, PM2.5, PM10) and particle counts in various air volumes. It is compatible with Arduino and other platforms that support the Arduino framework.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Basic Example](#basic-example)\n  - [Advanced Example](#advanced-example)\n- [API Reference](#api-reference)\n- [Dependencies](#dependencies)\n- [License](#license)\n- [Author](#author)\n\n## Features\n\n- Supports both UART and I2C communication modes.\n- Reads PM1.0, PM2.5, and PM10 concentrations in µg/m³.\n- Retrieves particle counts for various air volumes (300 mL, 0.5 L, 1 L, 2.5 L, 5 L, 10 L).\n- Provides measurement context switching (Standard or Atmospheric).\n- Includes sensor connection status checking.\n- Lightweight and efficient implementation.\n\n## Installation\n\n1. **Download the Library**:\n   - Clone or download this repository to your local machine.\n\n2. **Install the Library**:\n   - Copy the folder containing the `MPM10.h` and related files to the `libraries` folder in your Arduino IDE sketchbook directory. For example:\n     ```\n     \u003csketchbook\u003e/libraries/MPM10/\n     ```\n\n3. **Install Dependencies**:\n   - Ensure the required dependencies (listed in the [Dependencies](#dependencies) section) are installed.\n\n4. **Restart the Arduino IDE**:\n   - Restart the Arduino IDE to make the library available under the `Sketch \u003e Include Library` menu.\n\n## Usage\n\n### Basic Example\n\nBelow is a basic example of using the `MPM10` library to read PM1.0, PM2.5, and PM10 concentrations using I2C mode:\n\n```cpp\n#include \u003cMPM10.h\u003e\n\nMPM10 sensor; // Default constructor for I2C mode\n\nvoid setup() {\n  Serial.begin(9600);\n  while (!Serial); // Wait for Serial Monitor to open\n\n  if (sensor.isConnected()) {\n    Serial.println(\"MPM10 sensor connected successfully!\");\n  } else {\n    Serial.println(\"Failed to connect to MPM10 sensor!\");\n    while (1); // Halt execution\n  }\n}\n\nvoid loop() {\n  MPM10_DATA data = sensor.readData();\n\n  if (data.valid) {\n    Serial.print(\"PM1.0: \"); Serial.print(data.pm1_0); Serial.println(\" µg/m³\");\n    Serial.print(\"PM2.5: \"); Serial.print(data.pm2_5); Serial.println(\" µg/m³\");\n    Serial.print(\"PM10: \"); Serial.print(data.pm10); Serial.println(\" µg/m³\");\n  } else {\n    Serial.println(\"Invalid data received from sensor!\");\n  }\n\n  delay(1000); // Wait 1 second before the next reading\n}\n```\n\n### Advanced Example\n\nThis example demonstrates how to use UART mode, change the measurement context, and retrieve particle counts for different air volumes:\n\n```cpp\n#include \u003cMPM10.h\u003e\n\nMPM10 sensor(17, 16); // Constructor for UART mode (TX pin 17, RX pin 16)\n\nvoid setup() {\n  Serial.begin(9600);\n  while (!Serial); // Wait for Serial Monitor to open\n\n  if (sensor.isConnected()) {\n    Serial.println(\"MPM10 sensor connected successfully!\");\n  } else {\n    Serial.println(\"Failed to connect to MPM10 sensor!\");\n    while (1); // Halt execution\n  }\n\n  // Set measurement context to atmospheric\n  sensor.setMeasurementContext(MPM10_ATM_CONTEXT);\n}\n\nvoid loop() {\n  MPM10_DATA data = sensor.readData();\n\n  if (data.valid) {\n    Serial.print(\"PM1.0: \"); Serial.print(data.pm1_0); Serial.println(\" µg/m³\");\n    Serial.print(\"PM2.5: \"); Serial.print(data.pm2_5); Serial.println(\" µg/m³\");\n    Serial.print(\"PM10: \"); Serial.print(data.pm10); Serial.println(\" µg/m³\");\n\n    // Read particle counts in various air volumes\n    Serial.print(\"Particles in 300 mL: \"); Serial.println(sensor.getPMIn300mL());\n    Serial.print(\"Particles in 1 L: \"); Serial.println(sensor.getPMIn1L());\n    Serial.print(\"Particles in 10 L: \"); Serial.println(sensor.getPMIn10L());\n  } else {\n    Serial.println(\"Invalid data received from sensor!\");\n  }\n\n  delay(5000); // Wait 5 seconds before the next reading\n}\n```\n\n## API Reference\n\n### Class: `MPM10`\n\n#### Constructors\n\n- `MPM10()`  \n  Default constructor for I2C mode.\n\n- `MPM10(uint8_t tx, uint8_t rx)`  \n  Constructor for UART mode, specifying the TX and RX pins.\n\n#### Methods\n\n- `MPM10_DATA readData()`  \n  Reads and returns the sensor data (PM1.0, PM2.5, PM10, and validity status).\n\n- `void setMeasurementContext(uint8_t context)`  \n  Sets the measurement context. Use `MPM10_STD_CONTEXT` for standard mode or `MPM10_ATM_CONTEXT` for atmospheric mode.\n\n- `uint16_t getPMIn300mL()`  \n  Returns the number of particles \u003e0.1 µm in 300 mL of air.\n\n- `uint16_t getPMIn500mL()`  \n  Returns the number of particles \u003e0.1 µm in 0.5 L of air.\n\n- `uint16_t getPMIn1L()`  \n  Returns the number of particles \u003e0.1 µm in 1 L of air.\n\n- `uint16_t getPMIn2_5L()`  \n  Returns the number of particles \u003e0.1 µm in 2.5 L of air.\n\n- `uint16_t getPMIn5L()`  \n  Returns the number of particles \u003e0.1 µm in 5 L of air.\n\n- `uint16_t getPMIn10L()`  \n  Returns the number of particles \u003e0.1 µm in 10 L of air.\n\n- `bool isConnected()`  \n  Checks if the sensor is connected and returns `true` if connected, `false` otherwise.\n\n#### Data Structure: `MPM10_DATA`\n\nThe `MPM10_DATA` structure is used to store sensor data and includes the following fields:\n\n- `uint16_t pm1_0` – PM1.0 concentration in µg/m³.\n- `uint16_t pm2_5` – PM2.5 concentration in µg/m³.\n- `uint16_t pm10` – PM10 concentration in µg/m³.\n- `bool valid` – `true` if the data is valid, `false` otherwise.\n\n## Dependencies\n\n- **Arduino Framework**: Required for basic functionality and hardware abstraction.\n- **SensorHub Library**: A custom library used for communication with the sensor (ensure it is installed and available in your project).\n\n## License\n\nThis project is licensed under the MIT License. See the `LICENSE` file for details.\n\n## Author\n\nSaurav Sajeev  \nFor questions or contributions, please contact the author or open an issue on this repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyropyr0%2Fmpm10","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstyropyr0%2Fmpm10","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyropyr0%2Fmpm10/lists"}