SDS011

by tommy_d in Circuits > Arduino

500 Views, 1 Favorites, 0 Comments

SDS011

dssdsds.jpg

The SDS011 is designed to detect the amount of dust in the air.

Supplies

dssdsds.jpg
us.jpeg
udino.jpg
jump.jpeg
  • 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.

Screenshot 2022-01-19 10.39.40.png
SDS011.png

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

Screenshot 2022-01-27 13.11.33.png

#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

Screenshot 2022-01-27 13.21.25.png
  • Push on the arrow "Upload and save".
  • Go to "monitor".
  • If everything works well, you will see the measurements.