# Port SDS011 Library

**URL:** <https://community.particle.io/t/port-sds011-library/25370>\
**Category:** Libraries\
**Created:** [August 26, 2016, 2:58am UTC](https://community.particle.io/t/port-sds011-library/25370 "2016-08-26T02:58:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichaelRensing](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@MichaelRensing](https://community.particle.io/u/MichaelRensing)\
**Post date:** [August 26, 2016, 2:58am UTC](https://community.particle.io/t/port-sds011-library/25370/1 "2016-08-26T02:58:41Z")

</div>

Can anyone assist me in porting this Arduino/ESP8266 library to Particle?

[Arduino\_sds011](https://github.com/kadamski/arduino_sds011)

My main program is fairly straightforward, but I know there is something wrong in the library. Particle Dev returns with “Compiler Timed out or encountered an error”. Any help is greatly appreciated.

Oh, and I have added the #include “Particle.h” to the Sds011.h file.

```
#include "SDS011.h"

static const int SAMPLES=10;

Sds011 sensor = Sds011(Serial1);

void setup()
{
    bool clear = true;
    Serial.begin(9600);
    Serial1.begin(9600);

    sensor.set_sleep(false);
    sensor.set_mode(sds011::QUERY);
}

void loop()
{
    int pm25, pm10;
    bool ok;

    sensor.set_sleep(false);
    delay(1000);
    ok = sensor.query_data_auto(&pm25, &pm10, SAMPLES);
    sensor.set_sleep(true);

    Serial.print("PM 2.5: "); Serial.println(String(pm25));
    Serial.print("PM 10: "); Serial.println(String(pm10));
    delay(60000);
}

```

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [August 26, 2016, 9:02am UTC](https://community.particle.io/t/port-sds011-library/25370/2 "2016-08-26T09:02:42Z")

</div>

Have you looked up some threads about porting libraries for Particle?

One important statement is

```cpp
#include "Particle.h"

```

And most `file not found` errors relate to files not needed anyway.

After you tried some of this on your attempt to port the lib, we will be happy to _assist_ 😉

Or did you mean: “Can someone port the library for me”?

---

<div class="post-metadata">

**Author:** ![MichaelRensing](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@MichaelRensing](https://community.particle.io/u/MichaelRensing)\
**Post date:** [August 26, 2016, 12:11pm UTC](https://community.particle.io/t/port-sds011-library/25370/3 "2016-08-26T12:11:10Z")

</div>

I have moved all the code out of the library, and into jus the main .ino. It chocked on the enum, and searching, I found that I needed to put them into a header. That didn’t fix it, so I declared them individually as ints. The main problem I am running into is that Particle Dev provides not help debugging the library files. If there is an error in one, I just get a the generic message of the compiler timed out or encountered an error. If it is in the main uno, it debugs.

Funny thing is that I really didn’t change the code. I removed the namespace from the library, re-worked the enum. But that was it. Since it is working in the main .ino, I am just going to leave it there for now and try to re-libraryize it later.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [August 26, 2016, 12:17pm UTC](https://community.particle.io/t/port-sds011-library/25370/4 "2016-08-26T12:17:38Z")

</div>

I prefer CLI (`particle compile photon path`) for building semi-locally, since that at least provides useful error messages (usually).

---

<div class="post-metadata">

**Author:** ![mellbratt](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mellbratt/32/15385_2.png) [@mellbratt](https://community.particle.io/u/mellbratt)\
**Post date:** [July 5, 2018, 9:53pm UTC](https://community.particle.io/t/port-sds011-library/25370/5 "2018-07-05T21:53:19Z")

</div>

Hey,

How did this work out for you? Do you have a working sketch for this sensor? 🙂
