Going in circles interfacing UnoR3 to PMS5003 & Screen

Hi.
I have set up my Uno, PMS5003, 10K pot & LCD screen & uploaded a sketch as per a website & video tutorial online.. however the narrator of the video speaks too fast in a very strong accent which I cannot easily follow & the screen resolution is poor (but thank you how2electronics.com) & the website has step by step guide but I am missing a vital step because the sketch loads (my 3rd or 4th go at running anything) but nothing happens.

I am missing 1 vital step which I cannot fathom. It gives a long code for the set up without a screen then it says this;

"The source code for interfacing PM2.5 PMS5003 Air Quality Sensor with Arduino and LCD Display is given below.
Simply copy the code and upload to the Arduino UNO Board.

But before that you need to add the library for PMS5003 Sensor. So simply install the following library from the library manager"

I have installed the library but I assume it needs to be referenced somehow..right ?
It gives this extra(?) coding... but where does that go ?..at the front or at the end of the initial coding ??

#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("Dust Concentration");
    lcd.setCursor(0, 1);
    lcd.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)");
    lcd.setCursor(0, 3);
    lcd.print("PM10  :" + String(data.PM_AE_UG_10_0) + "(ug/m3)");
    
    delay(1000);
  }
}

I hope I have explained myself adequately.
The guidelines said not to post any links.

Thanks in advance
Togs

the LCD doesn't display Warming up? If not, upload some simple LCD example code to get the LCD working. Divide and conquer

The screen illuminates & shows 2 rows of blocks,
I cannot hear the sensor's fan running,
TX LED is blinking,
Poti is working ( contrast is adjustable)

Thanks for helping Karma... but are you suggesting loading a sample sketch for the display on it's own ?

Yes. Sort out your LCD issue using the LCD example. I suspect you have a poor connection related to the LCD. Very common if using a breadboard and Dupont connectors. Double check your wiring.

Disconnect everything not LCD related.

I think this is our clue. Are you trying to power the monitor with the Uno? Don't to that. Did the monitor come with a power adaptor?

This is a 3.3V device. Do you have a level converter on your Uno Tx line?

Datasheet

And here comes ChatGPT I'm out.
Good luck

I have copied this wiring diagram & yes the breadboard & wiring pins are poor but all seem be be held in place.

The fan inside PMS is running & I have strange shaped characters continually increasing in the Serial Monitor .. as if it's measuring but not giving legible data.

I read the data sheet before connecting & questioned the supply voltage requirements but assumed as it's working in the example video so it mustn't matter that much.

I have no idea what you mean by Level converter but I will look into it.

TXD pin5 on Sensor has 3.3V

The screen came with a board on the back. The vcc on this extra board is unused but has 4.8v .

Like this? Ignore the red circle

Yes, excatly that.

I have read & (hopefully) understand the Level Converter/RT/ TX issue but I am not using the RX or TX pins on the Arduino or on that small piggybacked board. RXD from PMSs breakout board (?) goes to pin 2.

My local electronics shop is looking for a level converter for me.

You need to back up and make that display work for you. It's very simple. Follow the below link. Come back when the display is working and we'll modify your code to use it.

I just wanted to add;
Do Not consider removing the backpack from the LCD. The backpack is a much easier, cleaner way to interface the LCD. That is all I use.

Thanks Karma, that article explained things nicely.

No wonder it didn't work..

It also answered a question I had from the start which was " is this normal to use so many wires for such a simple set up".

I have (at last) had time & the energy to do as instructed - & it works.
It is very satisfying when something (even as simple as this) works & what's even better is that I am understanding more & more what I am doing.

I changed the sketch to space the words to suit my screen.. obviously, it's not rocket science .. more like child's play ..but still.

Hopefully I get a day off work this week so I can take a close look at this mini project & adapt the original sketch to get it working.

Any more advice/help is very much welcome.

I got the LCD to work then spent many days reading, watching, downloading, compiling, running, commenting, uncommenting, unzipping everything I can find about these PM Sensors that my head was about to pop...& all to find that the answer to why I couldn't get any legible read-out was written on the screen.

// If using serial, initialize it and set baudrate before starting!

Now, in my defence that doesn't tell me what that rate should be. As a beginner "Serial.begin(115200)" is not an instruction to me, for me to set my IDE baud rate to 115200. I had it at 9600 thinking I needed to match what it was from the sensor.

So, I have the display working, I have the PMS working... but I cannot get the screen to show the serial print/data. I have tried to figure it out myself, then asked Ai & it couldn't help either so could someone please help me out?

There isn't UART / i2C conflict is there ?

The PMS is UART, RX to PIN 2
The i2C LCD, SCL to A5 & SDA to A4 ( why not SCL - SCL, SDA-SDA ?)

This is what Ai did after a "data not declared error"

#include "Adafruit_PM25AQI.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 20, 4);  // Set the I2C address of your LEC 20x4 display

Adafruit_PM25AQI aqi = Adafruit_PM25AQI();
PM25_AQI_Data data;  // Declare data at the beginning

// ... (rest of the code remains the same)

void setup() {
  // ... (existing setup code)

  Serial.println("Adafruit PMSA003I Air Quality Sensor");

  // Initialize the I2C display
  lcd.begin(20, 4);
  lcd.backlight();

  // ... (existing setup code)
}

void loop() {
  // ... (existing loop code)

  Serial.println(F("---------------------------------------"));
  Serial.println(F("Concentration Units (standard)"));
  Serial.println(F("---------------------------------------"));
  Serial.print(F("PM 1.0: ")); Serial.print(data.pm10_standard);
  Serial.print(F("\t\tPM 2.5: ")); Serial.print(data.pm25_standard);
  Serial.print(F("\t\tPM 10: ")); Serial.println(data.pm100_standard);
  Serial.println(F("Concentration Units (environmental)"));
  Serial.println(F("---------------------------------------"));
  Serial.print(F("PM 1.0: ")); Serial.print(data.pm10_env);
  Serial.print(F("\t\tPM 2.5: ")); Serial.print(data.pm25_env);
  Serial.print(F("\t\tPM 10: ")); Serial.println(data.pm100_env);
  Serial.println(F("---------------------------------------"));
  Serial.print(F("Particles > 0.3um / 0.1L air:")); Serial.println(data.particles_03um);
  Serial.print(F("Particles > 0.5um / 0.1L air:")); Serial.println(data.particles_05um);
  Serial.print(F("Particles > 1.0um / 0.1L air:")); Serial.println(data.particles_10um);
  Serial.print(F("Particles > 2.5um / 0.1L air:")); Serial.println(data.particles_25um);
  Serial.print(F("Particles > 5.0um / 0.1L air:")); Serial.println(data.particles_50um);
  Serial.print(F("Particles > 10 um / 0.1L air:")); Serial.println(data.particles_100um);
  Serial.println(F("---------------------------------------"));

  // Display the data on the I2C LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("PM2.5: ");
  lcd.print(data.pm25_env);
  lcd.setCursor(0, 1);
  lcd.print("PM10: ");
  lcd.print(data.pm100_env);
  // ... Add more lines as needed

  delay(1000);
}

This was mine (or Ai's ??) other attempt:

#include "Adafruit_PM25AQI.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 20, 4);  // Set the I2C address of your LEC 20x4 display

// ... (rest of the code remains the same)

/* Test sketch for Adafruit PM2.5 sensor with UART or I2C */

#include "Adafruit_PM25AQI.h"

Could it be a power supply issue for the display ?.. I have ran another code & configuration that is set up with a breadboard power supply module.

It doesn't run properly (naturally) & initially no characters show on the display until I power the breadboard module & then some characters appear.. sadly they do not show the PMS data... but could it help explain part of the problem ?

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