Dust sensor Samyoung DSM501A



  • Does anyone have this sensor running with my sensors?

    I can get my node to connect, but have 3 different variations on the equation for the data and am getting odd results back (one stays at 24 and the other is 500,000+) !

    Here is the code I am using - you can see 2 of the 3 options for the conversion equation are commented out. Not sure which of them (if any) I should be using.

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * DESCRIPTION
     * 
     * Dust Sensor for SamYoung DSM501
     *   connect the sensor as follows :
     *    Pin 2 of dust sensor PM1      -> Digital 3 (PMW)
     *    Pin 3 of dust sensor          -> +5V 
     *    Pin 4 of dust sensor PM2.5    -> Digital 6 (PWM) 
     *    Pin 5 of dust sensor          -> Ground
     * Datasheet: http://www.samyoungsnc.com/products/3-1%20Specification%20DSM501.pdf
    * Contributor: epierre
    **/
    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #define MY_RF24_PA_LEVEL   RF24_PA_MIN
    #define MY_NODE_ID 65
    #define MY_RF24_CHANNEL (97)
    #define MY_PARENT_NODE_ID 0
    #define MY_PARENT_NODE_IS_STATIC
    //#define MY_REPEATER_FEATURE
    //#define MY_SIGNING_ATSHA204
    //#define MY_SIGNING_REQUEST_SIGNATURES 
    
    #include <SPI.h>
    #include <MySensors.h>  
    
    
    #define CHILD_ID_DUST_PM10            0
    #define CHILD_ID_DUST_PM25            1
    #define DUST_SENSOR_DIGITAL_PIN_PM10  6
    #define DUST_SENSOR_DIGITAL_PIN_PM25  3
    unsigned long SLEEP_TIME = 5*60000; // Sleep time between reads (in milliseconds)
    //VARIABLES
    int val = 0;           // variable to store the value coming from the sensor
    float valDUSTPM25 =0.0;
    float lastDUSTPM25 =0.0;
    float valDUSTPM10 =0.0;
    float lastDUSTPM10 =0.0;
    unsigned long duration;
    unsigned long starttime;
    unsigned long endtime;
    unsigned long sampletime_ms = 30000;
    unsigned long lowpulseoccupancy = 0;
    float ratio = 0;
    long concentrationPM25 = 0;
    long concentrationPM10 = 0;
    
    //MySensor gw;
    MyMessage dustMsgPM10(CHILD_ID_DUST_PM10, V_LEVEL);
    MyMessage msgPM10(CHILD_ID_DUST_PM10, V_UNIT_PREFIX);
    MyMessage dustMsgPM25(CHILD_ID_DUST_PM25, V_LEVEL);
    MyMessage msgPM25(CHILD_ID_DUST_PM25, V_UNIT_PREFIX);
    
    void presentation()  
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Dust Sensor DSM501", "1.4");
    
      // Register all sensors to gateway (they will be created as child devices)
      present(CHILD_ID_DUST_PM10, S_DUST, "PM10");  
      send(msgPM10.set("ppm"));
      wait(100);
      present(CHILD_ID_DUST_PM25, S_DUST, "PM25");  
      send(msgPM25.set("ppm"));
      
      pinMode(DUST_SENSOR_DIGITAL_PIN_PM10,INPUT);
      pinMode(DUST_SENSOR_DIGITAL_PIN_PM25,INPUT);
      
    }
    
    void loop()      
    {    
      //get PM 2.5 density of particles over 2.5 μm.
      concentrationPM25=(long)getPM(DUST_SENSOR_DIGITAL_PIN_PM25);
      Serial.print("PM25: ");
      Serial.println(concentrationPM25);
      Serial.print("\n");
    
      if ((concentrationPM25 != lastDUSTPM25)&&(concentrationPM25>0)) {
          send(dustMsgPM25.set((long)ceil(concentrationPM25)));
          lastDUSTPM25 = ceil(concentrationPM25);
      }
     //get PM 1.0 - density of particles over 1 μm.
      concentrationPM10=getPM(DUST_SENSOR_DIGITAL_PIN_PM10);
      Serial.print("PM10: ");
      Serial.println(concentrationPM10);
      Serial.print("\n");
      //ppmv=mg/m3 * (0.08205*Tmp)/Molecular_mass
      //0.08205   = Universal gas constant in atm·m3/(kmol·K)
      int temp=20; //external temperature, if you can replace this with a DHT11 or better 
      long ppmv=(concentrationPM10*0.0283168/100/1000) *  (0.08205*temp)/0.01;
      
      if ((ceil(concentrationPM10) != lastDUSTPM10)&&((long)concentrationPM10>0)) {
          send(dustMsgPM10.set((long)ppmv));
          lastDUSTPM10 = ceil(concentrationPM10);
      }
     
      //sleep to save on radio
      sleep(SLEEP_TIME);
      
    }
    
    
    long getPM(int DUST_SENSOR_DIGITAL_PIN) {
    
      starttime = millis();
    
      while (1) {
      
        duration = pulseIn(DUST_SENSOR_DIGITAL_PIN, LOW);
        lowpulseoccupancy += duration;
        endtime = millis();
        
        if ((endtime-starttime) > sampletime_ms)
        {
        ratio = (lowpulseoccupancy-endtime+starttime)/(sampletime_ms*10.0);  // Integer percentage 0=>100
       // long concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve
        //  long concentration = (0.1 * pow(ratio, 2)) + (619 * ratio) + 50; //For DSM501A....
        long concentration = (0.0026 * pow(ratio, 2)) + (0.0859 * ratio) - 0.0184; //Equations based on Samyoung DSM501A spec sheet
        //Serial.print("lowpulseoccupancy:");
        //Serial.print(lowpulseoccupancy);
        //Serial.print("\n");
        //Serial.print("ratio:");
        //Serial.print(ratio);
        //Serial.print("\n");
        //Serial.print("DSM501A:");
        //Serial.println(concentration);
        //Serial.print("\n");
        
        lowpulseoccupancy = 0;
        return(concentration);    
        }
      }  
    }
    

    All hints and help appreciated! 😉


  • Hardware Contributor

    Hello, I think you would waste much less time buying a Plantower PMS5003 or PMS7003.
    This sensor has no fan so it will never be properly calibrated even if you spend hundreds of hours tuning it.

    For 12-15$ Plantower sensors will give you relatively accurate results out of the box.



  • @Nca78

    Thanks for the reply. But I don't see any examples for those sensors in the 'build' section. As it is, I woud very much like to get what I have purchased working before spending more on another sensor that has no support.

    Thanks for taking the time to reply though, much appreciated and I will remember this for the future.


  • Hardware Contributor

    I have a bunch of sensors from Plantower and Honeywell, I will post some examples in September (I'm away on holidays now) using those sensors and displaying AQI on LCD.

    The point I was trying to make in my previous message is you cannot really make this sensor work. With no fan and no decent factory calibration you cannot have reliable data. Look at the data sheet, the curves for min/max value are somewhere around +/-60% from real value. As air flow is generated from heating resistor results will also depend a lot on the temperature.



  • @Nca78

    Thanks for that, very kind of you. I am envious that you are on holiday now and will be until September(!)...

    As for this node I am trying to get functional, there is no need for scientific level measurements (that will be for another node soon) but merely to tell if the level of dust in a room is increasing, decreasing or has reached a preset level.


  • Plugin Developer

    I've built this with the Plantower sensor and have put the code on this forum. I also tried to get this to be the new 'default' dust sensor on the website, but for reasons I still don't quite understand it was never accepted as such.

    Be careful, there are a lot of outdates sensors on the website.

    Temperature / humudity -> check out the BME280 sketch I posted on the forum.
    CO2 -> check out the sketch I posted.



  • Hello,
    i'm working on the Samyoung DSM501A dust sensor.
    I would like to share my results with you, and ask you if someone has used this sensor too.
    This sensor works like the Shinyei PPD42NS.
    To get particle values > 1um, i read low ratio from output Vout2 (look at the datasheet).
    To convert it to something usefull, this function.
    concentration_pcs283ml = 0.02791 * ratio2^2 + 614.1*ratio2 + 4.926

    This function is derivated doing polinomial fit from the low ratio vs particle (pcs/283ml) graph you can find in the datasheet.
    There is another interesting graph in datasheet, that let use correlate low ratio to ug/m^3.
    The derivated function is:
    concentration_mgm3 = 0.001915 * ratio1^2 + 0.09522 * ratio1 - 0.04884

    I use the same functions read above to convert value read from the Vout1, with control pin open (no connection), which should be for particles > 2.5um.

    Now the questions:

    1. do you see something wrong in what i've done above?
    2. I - actually - don't have any instrument to correlate the value i read to PM1 or PM2.5 real values. Do you have instruments to do this?
    3. If i substract concentration_mgm3-forVout1 to concentration_mgm3-forVout2 i should find particles with diameter between 1um and 2.5um, so i can find PM25 particles, right?


  • @Johhnywalter

    I don't have equipment to test this, sorry. I only wanted an indication of the level of dust in a bedroom. But for now I have shelved this as I have more ijmportant things to take care of.


Log in to reply
 

Suggested Topics

  • 4
  • 274
  • 9
  • 14
  • 3
  • 5

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts