SDS011 Nova PM Sensor Laser PM2.5 Air Quality Detection Sensor Module Dust Sensor Air Conditioning Monitor Module
-
RM180.00
- Product Code: SDS011
- Availability: In Stock
Specification:
Power requirements
Features:
Documents:
Wire Connection:
Code:
#include "SdsDustSensor.h"
int rxPin = 0;
int txPin = 1;
SdsDustSensor sds(rxPin, txPin);
void setup() {
Serial.begin(9600);
sds.begin();
Serial.println(sds.queryFirmwareVersion().toString()); // prints firmware version
Serial.println(sds.setActiveReportingMode().toString()); // ensures sensor is in 'active' reporting mode
Serial.println(sds.setContinuousWorkingPeriod().toString()); // ensures sensor has continuous working period - default but not recommended
}
void loop() {
PmResult pm = sds.readPm();
if (pm.isOk()) {
Serial.print("PM2.5 = ");
Serial.print(pm.pm25);
Serial.print(", PM10 = ");
Serial.println(pm.pm10);
// if you want to just print the measured values, you can use toString() method as well
Serial.println(pm.toString());
} else {
// notice that loop delay is set to 0.5s and some reads are not available
Serial.print("Could not read values from sensor, reason: ");
Serial.println(pm.statusToString());
}
delay(500);
}