🚚 Free delivery on orders over: €35 Croatia • €60 EU • $100 US

HUM: PLANTOWER PMS5003

HUM: PLANTOWER PMS5003-Uncategorized

You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include technical characteristics, work principles, instructions on how to connect the module with Dasduino and the basic code. Everything else is left to your imagination.

INTRODUCTION

PMS5003 is a type of universal digital sensor for measuring particulate matter in the air,
which can also be used to obtain information on air purity.

SPECIFICATIONS

BASIC
• Operating voltage: 4.95 ~ 5.05V
• Maximum current: 120mA
• Current at standstill: ≤200 uA
• Response time: ≤10 s
• Operating temperature range: -20 ~ 50C
• Operating humidity range: 0 ~ 99% RH
• Maximum size: 65 × 42 × 23 (mm)

HIGHLIGHTS
• Quick response
• Kalibracijska krivulja drugog reda u više točaka ??? Calibration curve of the second row in multiple points
• Minimum resolution 0,3 microns

WORK PRINCIPLE

The sensor uses the laser scattering principle, i.e. it produces dispersion using a laser for radiation of the suspended particles in the air and then harvests that light to a certain degree until we finally get the scattering light variation curve. Lastly, we have the equivalent particle diameter and the number of particles with different diameters per volume unit that can be calculated using a microprocessor based on the MIE theory.

The sensor’s work principle block scheme

 

PINS

•PIN1 (VCC) – positive voltage 5V
•PIN2 (GND) – zero potential
•PIN3 (SET) – 3.3V active 0V/GND inactive, not necessary to connect if you do not use the inactive mode because it is connected via a pull-up resistor on the inside
•PIN4 (RX) – Serial port RX pin / TTL level@3.3V
•PIN5 (TX) – Serial port TX pin / TTL level@3.3V
•PIN6 (RESET) – Module reset signal / TTL level@ 3.3V, low reset
•PIN7/8 (NC) – Not connected

CONNECTING AND CODE

To connect this module, we will use three of its pins. Two for power supply and one pin using which the module will send data to Dasduino via serial connection.

#include //use a serial library
    SoftwareSerial pmsSerial(2, 3);//TX RX transmission and receiving line
     
    void setup() {
      
      Serial.begin(115200);//receiving line
     
      // Sensor baud rate 9600
      pmsSerial.begin(9600);//the line for communication with the PMS sensor
    }
     
    struct pms5003data {//the uint16_t declaration that has a value ranging from 0 to 65,535
      uint16_t framelen;
      uint16_t pm10_standard, pm25_standard, pm100_standard;
      uint16_t pm10_env, pm25_env, pm100_env;
      uint16_t particles_03um, particles_05um, particles_10um, particles_25um, particles_50um, particles_100um;
      uint16_t unused;
      uint16_t checksum;
    };//creating data structure
     
    struct pms5003data data;
        
    void loop() {
      if (readPMSdata(&pmsSerial)) {//if there is data coming from a receiving line, then:
        
        Serial.println("---------------------------------------");
        Serial.print("The particulate matter > 0.3um / 0.1L of air:");
Serial.println(data.particles_03um);//The particulate matter larger than 0.3 um
        Serial.print("The particulate matter > 0.5um / 0.1L of air:");
Serial.println(data.particles_05um);//The particulate matter larger than 0.5 um
        Serial.print("The particulate matter > 1.0um / 0.1L of air:");
Serial.println(data.particles_10um);//The particulate matter larger than 1 um
        Serial.print("The particular matter > 2.5um / 0.1L of air:");
Serial.println(data.particles_25um);//The particulate matter larger than 2.5 um
        Serial.print("The particulate matter > 5.0um / 0.1L of air:");
Serial.println(data.particles_50um);//The particulate matter larger than 5 um
        Serial.print("The particulate matter > 10.0 um / 0.1L of air:");
Serial.println(data.particles_100um);//The particulate matter larger than 10 um
        Serial.println("---------------------------------------");
      }
    }
     
    boolean readPMSdata(Stream *s) {
      if (! s->available()) {
        return false;
      }
      
      //read the byte bit by bit until you get a '0x42' starter byte
      if (s->peek() != 0x42) {
        s->read();
        return false;
      }
     
      // now read all 32 bytes
      if (s->available() < 32) { return false; } uint8_t buffer[32]; uint16_t sum = 0; s->readBytes(buffer, 32);
     
      // checking everything using the checksum
      for (uint8_t i=0; i<30; i++) {
        sum += buffer[i];
      }
     
    
      
      // The data come in the endian'd protocole, this part of the code allows support on all platforms
      uint16_t buffer_u16[15];
      for (uint8_t i=0; i<15; i++) {
        buffer_u16[i] = buffer[2 + i*2 + 1];
        buffer_u16[i] += (buffer[2 + i*2] << 8);
      }
     
      // save everything to the structure
      memcpy((void *)&data, (void *)buffer_u16, 30);
     
      if (sum != data.checksum) {
        Serial.println("Checksum failure");
        return false;
      }
      // when you succeed, return the result
      return true;
    }

 

FINAL RESULT

For the Serial monitor from Dasduino, we use the CTRL+SHIFT+M shortcut within the Arduino IDE program. After that, the Serial monitor, using which we will receive information from our sensor, opens.

Notice how the sensor readings are divided into 6 categories depending on the size of the detected particles in the air.
————————————————–
• There are 6942 particles larger than 0.3μm in 0.1L of air
• There are 2052 particles larger than 0.5μm in 0.1L of air
• There are 332 particles larger than 1.0μm in 0.1L of air
• There are 34 particles larger than 2.5μm in 0.1L of air
• There are 4 particles larger than 5.0μm in 0.1L of air
• There are 0 particles larger than 10.0μm in 0.1L of air

Please note that this module needs to be calibrated before being used in more serious projects.