strange behaviour with DSM501A dust module

Hello. I am building an environmental station and i am experiencing a strange behaviour with DSM501A dust module. I implement the same code in two different sketches and i take different results.

The code is:

void setup() {

void loop() {

  dust = readDustSensor();      //   -    float number (particles / 0.01 cubic feet)
  Serial.print(F("dust concentration = "));
  Serial.print(F("pcs/0.01cf "));

float readDustSensor() {                                                        //dust implementation
  unsigned long duration;
  unsigned long startTime;
  unsigned long sampletime_ms = 30000;                                   //time to take measure  
  unsigned long lowpulseoccupancy = 0;
  float ratio = 0;
  float concentration = 0;

  startTime = millis();                                                 //get the current time;

  do {
    duration = pulseIn(7, HIGH);
    lowpulseoccupancy = lowpulseoccupancy+duration;
  } while( (millis()-startTime) <= sampletime_ms );

  ratio = lowpulseoccupancy/(sampletime_ms*10.0);                       // Integer percentage 0=>100
  concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62;     // using spec sheet curve
  return concentration;  

When i upload a standalone sketch with this function only, i take the the results that first picture shows (which i believe that the correct ones). When i upload the function to my whole project i take strange results, too big than expected (second picture).

Can someone help me if he experienced a similar situation with this module?

(in the pictures i count the duration that comes from pulseIn functionality)

First: don't post pictures of text data. Copy the text data and paste it directly into your post.

To your problem: I doubt that the sensor reacts differently depending on the sketch you load to your Arduino. So most probably you do something in your main sketch that influences the measurement of the data the sensor supplies. As you're hiding the code of your main sketch from us you're left alone to debug the reason for this behavior.