Git Product home page Git Product logo

dsm501-interrupt's Introduction

DSM501 Interrupt

This library aims to implement the reading of DSM501 PWM pulse using external interrupt. It has been tested on Arduino Uno and ESP8266.

Hardware connection

Both sensor pins must be connected to interrupt pin on your desired board. For Arduino Uno, there are only two interrupt pins, which are on pin D2 and pin D3.

On the other hand, all pins on ESP8266 can be used for interrupt event except for D4, which cause the board to reset.

Code usage

First DSM501 object must be instantiated as shown below

DSM501 dsm501;

After that, the object is initialized with 3 parameters: PM1.0 pin, PM2.5 pin and a desired sample time

dsm501.begin(DSM501_PM1_0, DSM501_PM2_5, SAMPLE_TIME);

A piece of code is included in the example to delay for 60 seconds to wait for the heater in the module to heat up and stabilized before reading the result.

// Wait 60s for DSM501 to warm up
Serial.println("Wait 60s for DSM501 to warm up"); 
for (int i = 1; i <= 60; i++)
{
    delay(1000); // 1s
    Serial.print(i);
    Serial.println(" s (wait 60s for DSM501 to warm up)");
}
Serial.println("DSM501 is ready!");

Once the initialization is compete dsm501.update() is used to check if the sample time is reached and ready for the sensor value to be read.

if (dsm501.update())
{
    long particleCountPM1_0 = dsm501.getParticleCount(0);
    long particleCountPM2_5 = dsm501.getParticleCount(1);
    float concentration = dsm501.getConcentration();
}

getParticleCount(int i) is written specifically to get the number of particle counts in parts/283mLโ€‹ or parts/0.1cf. Index 0 is the number of counts for any particle larger than PM1.0, Index 1 is the number of counts for any particle larger than PM2.5.

getConcentration() uses the number of particle counts between PM1.0 and PM2.5, then estimates the concentration in ug/m^3. The estimation is based on a Journal on Atmospheric Environment (https://www.researchgate.net/publication/216680944_Estimation_of_particle_mass_concentration_in_ambient_air_using_a_particle_counter). It is done by assuming that all particles are spherical with an average radius r = 0.44um and a density D = 1.65x10^12ug/m^3.

dsm501-interrupt's People

Contributors

sovichea avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

maruthism

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.