SDS011

Hello guy's I whant to Programm an SDS011 Air Particle Dust Sensor for a school projekt i seached online but every code i saw got a serial command and i cant figure out what it used for and in my code i got an error everytime.

#include <SDS011.h>

float p10, p25;
int error;

SDS011 my_sds;

void setup() {
my_sds.begin(&Serial1);
Serial.begin(115200);
}

void loop() {
error = my_sds.read(&p25, &p10);
if (!error) {
Serial.println("P2.5: " + String(p25));
Serial.println("P10: " + String(p10));
}
delay(100);
}

This code errors every time

Maybe state what Arduino you are using and what the error message says.
Likely is that you are not using an Arduino with a second hardware serial port and will have to try using software serial instead. Serial1 here is a second hardware serial port.

SDS011 my_sds;

Well, who else's would it be?

What's wrong with using a name, like dustSensor, that makes sense?