IF Statement on Sensor

so I have created an air pollution sensor to display values on an LCD (4X20) and it all works fine except for the fact that on the fourth line, I want to display the following
If PM10 value > 30 then the LCD displays bad quality, but if
PM10 value > 20 then the LCD displays mediocre quality and finally of
PM10 value > 0 then the LCD displays good quality.
When I uploaded the code on my arduino board it displays “bad quality” no matter what the values are?
Thank You So Much!

#include "PMS.h"
#include "SoftwareSerial.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

SoftwareSerial Serial1(2, 3); // RX, TX

PMS pms(Serial1);
PMS::DATA data;

void setup()
  lcd.setCursor(0, 0);
  lcd.print("Warming up");

void loop()
  if (pms.read(data))
    lcd.setCursor(0, 0);
    lcd.print("Particle Pollution");
    lcd.setCursor(0, 1);
    lcd.print("PM2.5 :" + String(data.PM_AE_UG_2_5) + "(ug/m3)");
    lcd.setCursor(0, 2);
    lcd.print("PM10  :" + String(data.PM_AE_UG_10_0) + "(ug/m3)");
    lcd.setCursor(0, 3);
    if (String(data.PM_AE_UG_10_0>30))
      lcd.print("bad quality");
      else lcd.print("good quality");

if (String(data.PM_AE_UG_10_0>30))

What should happen when you compare a String to a number? Would it not be better to compare a number to a number?

Does that line generate a warning?

It does not display a warning but, I was thinking about how I can define the values but I am unsure on how to do that? any advice?
Kind Regards,

First we need to know the data type of the data.PM_AE_UG_10_0 which is a member variable of the PMS library. So we look in the PMS.h file for the declaration of PM_AE_UG_10_0. We see:

uint16_t PM_AE_UG_10_0;

in the declaration of the DATA struc.

So PM_AE_UG_10_0 is what we would call an unsigned int so it is already a number.

What happens when you replace that line with:

if (data.PM_AE_UG_10_0 > 30)


I would be a good idea for you to get away from using the String class in your Arduino programs. Misusing the String class can cause memory problems over time. Here is why the String class is to be avoided. There are also hints on c_string functions to use to replace the String functions.

You could rewrite:

lcd.print("PM10  :" + String(data.PM_AE_UG_10_0) + "(ug/m3)");


    lcd.print("PM2.5 : "); 

And avoid the String class.