Port SDS011 Library

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


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;


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

    ok = sensor.query_data_auto(&pm25, &pm10, SAMPLES);

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

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

One important statement is

#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 :wink:

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

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.

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


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