SDS011
The SDS011 is designed to detect the amount of dust in the air.
Supplies
- 4 male-to-female jumper wires.
- USB for Arduino.
- Computer or laptop.
- SDS011-sensor.
- Arduino Editor to import the code (https://create.arduino.cc/editor).
- Arduino-board UNO 65139 ATMega328.
Before we start I would like to say that the colors I've used for the wires really don't matter. They are just randomly chosen so, for example, if you don't have an orange wire, you can just use a black one, it will work too.
- Connect the first wire (blue) from TXD on your sensor to RX<-0 on your arduino.
- Connect the second wire (orange) from RXD on your sensor to TX->1 on your arduino
- Connect the third wire (black) from ground (GND) to ground on the arduino.
- Connect the forth wire (green) from 5V to 5V.
- Login on arduino editor to import the code from step 2.
- If you open a new sketch you will see that there is already some code on it, remove that code and copy the code from step 2.
- Paste the code on your empty sketch.
PROGRAMMING
#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()); // ensure sensor is in 'active' reporting mode
Serial.println(sds.setContinuousWorkingPeriod().toString());
}
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 .5s
Serial.print("could not read values from sensor, reason: ");
Serial.println(pm.statusToString());
}
delay(500);
}
TESTING
- Push on the arrow "Upload and save".
- Go to "monitor".
- If everything works well, you will see the measurements.