Arduino Uno isn't reading data from PMS5003 air sensor

Hi Forum Members,

Everything is hooked up and running fine except one thing: the sensor data is all zeroes on my serial monitor. FWIW this is my first exposure to Arduino, and I'm trying to learn as I go.

At this point, it's all very basic. The Uno is hooked up to the sensor with just 4 wires, sensor to Arduino, 5v to 5V, ground to ground, tx to rx (pin 0), and rx to tx (pin 1).

I installed the Arduino IDE, added the PMS library, and uploaded the simplest possible code. Here is it:

#include "PMS.h"

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

void setup()
{
  Serial.begin(9600);   // GPIO1, GPIO3 (TX/RX pin on ESP-12E Development Board) 
  //Serial1.begin(9600);  // GPIO2 (D4 pin on ESP-12E Development Board)
}

void loop()

{

//if (pms.read(data)) {
  Serial.print("ok");
  Serial.println();
  
    Serial.print("PM 1.0 (ug/m3): ");
    Serial.println(data.PM_AE_UG_1_0);

    Serial.print("PM 2.5 (ug/m3): ");
    Serial.println(data.PM_AE_UG_2_5);

    Serial.print("PM 10.0 (ug/m3): ");
    Serial.println(data.PM_AE_UG_10_0);

    Serial.println();
  }

The purpose of the commented if statement was to determine if Arduino was reading the data. It wasn't. The sketch outputs the lines but the readings are all zero, in other words no data, even with some smoke.

Now I'm reading that the problem may related to 5v vs 3.3v logic. Apparently, the sensor runs at 3.3.

Based on what I could find so far, I'm stuck with a few questions.

  1. Is that the most likely problem?
  2. Is the best solution a logic level converter?
  3. Did I probably damage my sensor?

Any help is greatly appreciated!

Vince

Please post a link to the sensor, and state which Arduino you are using. If it is the Uno, you cannot normally use pins 0 and 1 for serial data as those are reserved for program upload and debugging.

When starting with a new device and device library, always wire according to the library example, and make sure that a library example works correctly before doing anything else.

If you are using the Adafruit PMS5003 sensor, follow their "getting started" guide to the letter.

That sounds about what I would expect. Pin 0 and pin 1 are for the serial console on the Arduino UNO. Doing it the way you are is possible but not straight forward. There are two possible solutions: First use software serial or use a different Arduino that has more then one serial port.

Here's a link to the datasheet. It should be the same sensor as the Adafruit one. I didn't find their "getting started" guide, but saw this: https://cdn-learn.adafruit.com/downloads/pdf/pm25-air-quality-sensor.pdf

That's a little heavy for me at this point. Also it's geared their Metro instead of the Uno.

If I don't use pins 0 and 1, what's the best alternative? Software serial as gilshultz mentioned?

Sorry, missed datasheet link: https://www.digikey.jp/htmldatasheets/production/2903006/0/0/1/pms5003-series-manual.html

That is a 3.3V device. You cannot connect the data pins to a 5V Arduino without using logic level shifters for RX and TX. You may already have damaged the sensor, the Uno, or both.

From the data sheet:

With the Uno, your only option is to use SoftwareSerial, with logic level shifters.

That's a little heavy for me at this point.

Then you are biting off a bit more than you are ready to chew with this project. I suggest to get some practical experience with simpler projects, or buy the Adafruit version of this sensor with logic level shifters already added, and follow their "getting started" instructions to the letter.

I'm not giving up that easily. I will look for a logic level shifter, hope the sensor doesn't need replacing, and report back. Thanks for the help.

This is what I use (when I have to): SparkFun Logic Level Converter - Bi-Directional

The much better choice is to use 3.3V processors with 3.3V sensors (which now constitute at least 95% of the market).

5V logic will soon be a thing of the past.

Now I have an update. I noticed in another discussion that there might be no damage to the sensor. The sensor takes 5v to run its fan, but it doesn't take 5v from tx port on the arduino. Instead it sends data at 3.3, which the Arduino should be able to read.

I took your advice, jremington, and looked at the Adafruit guide. I copied that code and modified it as they suggested for serial software. And then I noticed that it said to change the serial monitor to 11500 to view the results. It worked.

With the Adafruit code, the data wiring uses only one connection, from sensor tx to uno rx.

I already ordered the logic level shifter, but I'm not sure if I need it after all. Is it possible that all the data communication is only from sensor to Uno, and the Uno isn't providing power to it other than the 5v that the sensor needs for its fan? Sorry if these are silly questions, but again, I'm new at this.

Glad it seems to be working!

Successful communication from a 3.3V output to a 5V input is not guaranteed, but if you do receive data, the connection is at least electrically safe.

It is not electrically safe, and can even damage one or both devices to connect a 5V output to a 3.3V input.

Sending 5V to 3.3 being risky makes sense. But why is 3.3 to 5V risky, except that the devices may not function properly?

To me, "may not function properly" is an excellent reason not to do that.

The very best approach is to use 3.3V processors with 3.3V sensors, and 5V processors with 5V sensors.

Got it. Thanks for the reply.