Not getting data from PMS5003

Hi, I'm using a particulate matter sensor (PMS5003) to measure particles and display it on a 20x4 LCD display, I was facing a lot of errors due to the libraries but I figured it out and the full code runs now, but I'm not receiving any data from the sensor, this is my code:

#include <LiquidCrystal_I2C.h>
#include <PMS.h>
#include <SoftwareSerial.h>

//SDA = A4;
//SCL = A5;
LiquidCrystal_I2C lcd(0x27, 20, 4);
SoftwareSerial pmSerial(2,3); // RX, TX

//PMS pms(serial1);
PMS pms(pmSerial);
PMS::DATA data;

void setup() 
{
  Serial.begin(9600);
  //lcd.begin(20,4);
  lcd.init();
  lcd.setCursor(0, 0);
  lcd.print("Warming up");
  delay(4000);
  lcd.clear();
}

void loop()
{
  if (pms.read(data))
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Dust Concentration");
    Serial.print("Dust Concentration");
    lcd.setCursor(0, 1);
    lcd.print("PM1.0 :" + String(data.PM_AE_UG_1_0) + "(ug/m3)");
    Serial.print("PM1.0 :" + String(data.PM_AE_UG_1_0) + "(ug/m3)");
    lcd.setCursor(0, 2);
    lcd.print("PM2.5 :" + String(data.PM_AE_UG_2_5) + "(ug/m3)");
    Serial.print("PM2.5 :" + String(data.PM_AE_UG_2_5) + "(ug/m3)");
    lcd.setCursor(0, 3);
    lcd.print("PM10  :" + String(data.PM_AE_UG_10_0) + "(ug/m3)");
    Serial.print("PM10  :" + String(data.PM_AE_UG_10_0) + "(ug/m3)");
    delay(1000);
  }
}

did you write a program to test the particulate matter sensor (PMS5003) by itself?
did it work?

Im using the same code to test out the sensor by itself (without lcd just serial monitor) but still not getting anything

you don't aappear to set the baudrate for

pmSerial.begin(9600);

I added that and tested it out, still nothing..
Code now:

#include <LiquidCrystal_I2C.h>
#include <PMS.h>
#include <SoftwareSerial.h>

//SDA = A4;
//SCL = A5;
LiquidCrystal_I2C lcd(0x27, 20, 4);
SoftwareSerial pmSerial(2,3); // RX, TX

//PMS pms(serial1);
PMS pms(pmSerial);
PMS::DATA data;

void setup() 
{
  pmSerial.begin(9600);
  Serial.begin(9600);
  //lcd.begin(20,4);
  lcd.init();
  lcd.setCursor(0, 0);
  lcd.print("Warming up");
  Serial.print("Warming up");
  delay(4000);
  lcd.clear();
}

void loop()
{
  if (pms.read(data))
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Dust Concentration");
    Serial.print("Dust Concentration");
    lcd.setCursor(0, 1);
    lcd.print("PM1.0 :" + String(data.PM_AE_UG_1_0) + "(ug/m3)");
    Serial.print("PM1.0 :" + String(data.PM_AE_UG_1_0) + "(ug/m3)");
    lcd.setCursor(0, 2);
    lcd.print("PM2.5 :" + String(data.PM_AE_UG_2_5) + "(ug/m3)");
    Serial.print("PM2.5 :" + String(data.PM_AE_UG_2_5) + "(ug/m3)");
    lcd.setCursor(0, 3);
    lcd.print("PM10  :" + String(data.PM_AE_UG_10_0) + "(ug/m3)");
    Serial.print("PM10  :" + String(data.PM_AE_UG_10_0) + "(ug/m3)");
    delay(1000);
  }
}

what Arduino are you testing the PMS5003 with?
it uses 3.3V logic so don't connect it directly to an Arduiono which uses 5V logic such as the Uno
how have you connected it?

Arduino UNO rev3.
I just tested it out using voltage divider to power rx with 3.3volts using 1k and 2k resistors.

Do I need to connect rx, tx, SET, reset, all to 3.3v?

the voltage divider should be OK - have you an oscilloscope to look at the lines?
perhaps take pin 3 SET and pin6 reset to 3.3V thru a 10Kohm resistor as Figure 3 Typical Circuit as in plantower-pms5003-manual_v2-3

Hi, I'm using a particulate matter sensor (PMS5003) to measure particles and display it on a 20x4 LCD display, I was facing a lot of errors due to the libraries but I figured it out and the full code runs now, but I'm not receiving any data from the sensor, this is my code:

#include <LiquidCrystal_I2C.h>
#include <PMS.h>
#include <SoftwareSerial.h>

//SDA = A4;
//SCL = A5;
LiquidCrystal_I2C lcd(0x27, 20, 4);
SoftwareSerial pmSerial(2,3); // RX, TX

//PMS pms(serial1);
PMS pms(pmSerial);
PMS::DATA data;

void setup() 
{
  Serial.begin(9600);
  //lcd.begin(20,4);
  lcd.init();
  lcd.setCursor(0, 0);
  lcd.print("Warming up");
  delay(4000);
  lcd.clear();
}

void loop()
{
  if (pms.read(data))
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Dust Concentration");
    Serial.print("Dust Concentration");
    lcd.setCursor(0, 1);
    lcd.print("PM1.0 :" + String(data.PM_AE_UG_1_0) + "(ug/m3)");
    Serial.print("PM1.0 :" + String(data.PM_AE_UG_1_0) + "(ug/m3)");
    lcd.setCursor(0, 2);
    lcd.print("PM2.5 :" + String(data.PM_AE_UG_2_5) + "(ug/m3)");
    Serial.print("PM2.5 :" + String(data.PM_AE_UG_2_5) + "(ug/m3)");
    lcd.setCursor(0, 3);
    lcd.print("PM10  :" + String(data.PM_AE_UG_10_0) + "(ug/m3)");
    Serial.print("PM10  :" + String(data.PM_AE_UG_10_0) + "(ug/m3)");
    delay(1000);
  }
}

This is my connection, but I'm using an lcd that has i2c, LCD works fine, I'm just not getting any input from the sensor:

I'm using this page as a reference:

Could it be that I'm connecting pin 4 and 5 (RX and TX of the sensor) to pin 3 and 2 of the Arduino, instead of connecting them to RX and TX (pin 1 and 0) of the Arduino?

I have merged your cross-posts @rihamk.

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please take some time to pick the forum category that best suits the subject of your question and then only post once to that forum category. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

the example project is using pins 2 and 3 and SoftwareSerial - I assume you have 2 and 3 the correct way around
if I was doing this I would use an Arduino with 3.3V logic and hardware serial such as the Arduino Due - it makes like much simpler


So I need to connect 3.3v to set and reset and connect it to which pins of the arduino?

for now just connect them to 3.3V thru 10Kohn and hopefully it should run
I cannot see anything the basic example of PMS library where SET and RESET are used

I tested it out after connecting the way you told me to, it works perfectly fine now, thank you so much for your help!

So, weeks ago I got readings from the pms5003 and it was only once that it worked, since then I haven't been getting any data from it.
I'm using the same code:

#include <SoftwareSerial.h>
#include <PMS.h>

SoftwareSerial pmSerial(2,3);
PMS pms(pmSerial);
PMS::DATA data;

int rx = 2;
int tx = 3;

void setup() 
{
  pmSerial.begin(9600);
  Serial.begin(9600);
  Serial.print("Warming up");
  delay(4000);
  

}

void loop() 
{
  if (pms.read(data))
  {
    pmSerial.print("Dust Concentration");
    pmSerial.print('\n');
    pmSerial.print("PM1.0 :" + String(data.PM_AE_UG_1_0) + "(ug/m3)");
    pmSerial.print('\n');
    pmSerial.print("PM2.5 :" + String(data.PM_AE_UG_2_5) + "(ug/m3)");
    pmSerial.print('\n');
    pmSerial.print("PM10  :" + String(data.PM_AE_UG_10_0) + "(ug/m3)");
    pmSerial.print('\n');
    delay(1000);
  }
else
{
  Serial.println("no data");
  delay(1000);
  
}

  /*float rxval = digitalRead(rx);
  float txval = digitalRead(tx);
  
  Serial.print("Pin 2: ");
  Serial.println(rxval);
  Serial.print("Pin 3: ");
  Serial.println(txval);

  delay(10000);*/
}

Circuit:

I need help figuring out why I'm not receiving anything from the sensor now..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.