Hi,
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()
{
Serial1.begin(9600);
lcd.begin(20,4);
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("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");
delay(1000);
}
}