Skip to content

Anemo27/DSM501

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

DSM501 Arduino Library

Arduino

This Arduino library provides support for working with the DSM501 particulate matter sensor. It allows you to easily interface with the sensor and read particulate matter concentrations.

Table of Contents

Installation

  1. Download this repository as a ZIP file.
  2. In the Arduino IDE, go to Sketch > Include Library > Add .ZIP Library....
  3. Select the downloaded ZIP file.
  4. The library is now installed and ready to use.

Usage

  1. Include the library at the top of your Arduino sketch:

    #include "DSM501.h"
    
  2. Create an instance of the DSM501 class and specify the pin number and an interrupt handler function:

    int sensorPin = 2;  // Replace with your actual sensor pin
    DSM501 dsm501(sensorPin, yourInterruptHandler);
    
  3. Implement your interrupt handler function. This function will be called on each state change of the sensor's output pin:

    void yourInterruptHandler() {
    dsm501.handleInterrupt();
    }
  4. In your Arduino setup() function, initialize the sensor:

    void setup() {
    Serial.begin(9600);
    // Other setup code...
    dsm501.isReady(); // Warm-up the sensor
    }
  5. In your loop, you can read particulate matter concentrations:

    void loop() {
    float pmConcentration = dsm501.readPM();
    // Do something with the concentration value (e.g., display it or send it over a network)
    delay(1000); // Adjust the delay as needed
    }

Example

For a complete example sketch, check the examples folder in this repository.

Contributing

If you would like to contribute to this library, please create a fork of the repository, make your changes, and submit a pull request. Your contributions are greatly appreciated!

License

This library is released under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages