mysensors / MySensors

MySensors library and examples
https://www.mysensors.org
1.31k stars 892 forks source link

Dust Sensor DSM #1177

Open Laboltus opened 6 years ago

Laboltus commented 6 years ago

Hi.

May be I wrong but I guess you mixed something in examples/DustSensorDSM/DustSensorDSM.ino

ratio = (lowpulseoccupancy-endtime+starttime)/(sampletime_ms*10.0); // Integer percentage 0=>100

  1. lowpulseoccupancy is counted in microseconds but endtime+starttime are in milliseconds. You cannot just subtract one from the other.
  2. according to datasheet the formula is Low ratio[%] = t (sec) / 30 (sec) 100 so in code (after adjusting units of measure) it must look like this: ratio = lowpulseoccupancy/((endtime-starttime)10.00);
henrikekblad commented 6 years ago

Would be great if you could open a PR with your proposed changes to https://github.com/mysensors/MySensorsArduinoExamples