How can I measure value from dust sensor 'DSM501A' in 'microgram/m3'?

Hi all,

At first, I created easy project for measuing dust PM2.5 in the air by ESP8266 "NodeMCU E-12" with dust sensor. Then I buy PM2.5 Infrared Dust Sensor DSM501A from AliExpress below;

https://www.aliexpress.com/item/33044325098.html?srcSns=sns_Copy&spreadType=socialShare&bizType=ProductDetail&social_params=20137892438&aff_fcid=6eb67e3294d140cfb6851423e9c8ed57-1618172300372-02089-_mP1qlD9&tt=MG&aff_fsk=_mP1qlD9&aff_platform=default&sk=_mP1qlD9&aff_trace_key=6eb67e3294d140cfb6851423e9c8ed57-1618172300372-02089-_mP1qlD9&shareId=20137892438&businessType=ProductDetail&platform=AE&terminal_id=08cb638f15ca47658bc492e9822982e9&fbclid=IwAR010RkvORKEkCyRRG8EpRMFqVR5kGqa9-PXRM5PYSaHMhigUZETErfKElE

I try to search datasheet for my sensor, the below datasheet nearly my sensor model.

I connect Sensor with NodeMCU E-12 bellow:
Sensor Pin #1 not use
Sensor Pin #2 -> NodeMCU E-12 "D4"
Sensor Pin #3 -> NodeMCU E-12 "Vin"
Sensor Pin #4 -> NodeMCU E-12 "D6"
Sensor Pin #5 -> NodeMCU E-12 "GND"

I use my source code below:

int pin2 = D6;
int pin1 = D4;
unsigned long duration1;
unsigned long duration2;

unsigned long starttime;
unsigned long sampletime_ms = 3000;  //sampe 1s ;
unsigned long lowpulseoccupancy1 = 0;
unsigned long lowpulseoccupancy2 = 0;
float ratio1 = 0;
float ratio2 = 0;
float concentration1 = 0;
float concentration2 = 0;

void setup() {
    Serial.begin(9600);
    pinMode(D4, INPUT);
    pinMode(D6, INPUT);
    starttime = millis();  //get the current time;
}

void loop() {
    duration1 = pulseIn(pin1, LOW);
    duration2 = pulseIn(pin2, LOW);
    lowpulseoccupancy1 = lowpulseoccupancy1 + duration1;
    lowpulseoccupancy2 = lowpulseoccupancy2 + duration2;

    if ((millis() - starttime) > sampletime_ms)  //if the sampel time == 30s
    {
        ratio1 = lowpulseoccupancy1 / (sampletime_ms * 10.0);                                // Integer percentage 0=>100
        concentration1 = 1.1 * pow(ratio1, 3) - 3.8 * pow(ratio1, 2) + 520 * ratio1 + 0.62;  // using spec sheet curve

        ratio2 = lowpulseoccupancy2 / (sampletime_ms * 10.0);                                // Integer percentage 0=>100
        concentration2 = 1.1 * pow(ratio2, 3) - 3.8 * pow(ratio2, 2) + 520 * ratio2 + 0.62;  //

        Serial.println("PM10");

        Serial.print("concentration1 = ");
        Serial.print(concentration1);
        Serial.print(" pcs/0.01cf  -  ");

        Serial.print("concentration2 = ");
        Serial.print(concentration2);
        Serial.print(" pcs/0.01cf  -  ");

        if (concentration1 < 1000) {
            Serial.println("CLEAN");
        }
        if (concentration1 > 1000 && concentration1 < 10000) {
            Serial.println("GOOD");
        }

        if (concentration1 > 10000 && concentration1 < 20000) {
            Serial.println("ACCEPTABLE");
        }
        if (concentration1 > 20000 && concentration1 < 50000) {
            Serial.println("HEAVY");
        }

        if (concentration1 > 50000) {
            Serial.println("HAZARD");
        }
        lowpulseoccupancy1 = 0;
        lowpulseoccupancy2 = 0;
        starttime = millis();
    }
}

The sample output from Serial Monitor is below:

PM10
concentration1 = 360.14 pcs/0.01cf  -  concentration2 = 0.62 pcs/0.01cf  -  CLEAN
PM10
concentration1 = 102.13 pcs/0.01cf  -  concentration2 = 0.62 pcs/0.01cf  -  CLEAN
PM10
concentration1 = 529.45 pcs/0.01cf  -  concentration2 = 0.62 pcs/0.01cf  -  CLEAN
.....

I am not sure,
Does "pcs/0.01cf" value equal to "microgram/m3"? :cold_sweat:

If not, How can I measure value from dust sensor 'DSM501A' in 'microgram/m3'?

Please advise me.

Sorry your link does not work. The data sheet should tell you what it is measuring, it is up to the programer to convert that data to what is wanted.

Sorry about link. I am not sure, why you cannot open link.

The below is the sensor.

PM2.5 Infrared Dust Sensor DSM501A|ABS Sensor| - AliExpress

I think my sensor doesn't quite match the datasheet (above comment link). I've try to find out that exactly match, but not found.

Additional, refer above the output measuring, I feel 'concentration2' value is incorrect, because it has same value everytime.

So, I am not sure how can I solve this problem too. :pensive:

If you believe that datasheet is appropriate for your sensor, use its Figure 8-2 to find mg/m3 from the "low ratio" (either ratio1 or ratio2, depending on your needs). You can probably break Figure 8-2 into two linear regions without incurring much error.

Having two pulseIn() in a row may not accurately measure the low time for either of them within the 3 second window. Try reading the two pins in separate 3 second periods.

And no, "pcs/0.01cf" is not "mg/m^3" (nor is it ug/m^3). If you looked at the datasheet, you should have noticed that Figure 8-2 gives mg/m^3 vs low ratio, and Figure 8-3 gives pcs/283 ml vs low ratio. Clearly, they are different measures. One appears to be number of particles per unit volume, and the other is weight or mass per unit volume. And convert 283 ml to cubic feet to find out where your sketch's 0.01cf came from...

Thank you very much, DaveEvans. I will try again :grinning:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.