Due to high demand expect some shipping delays at this time, orders may not ship for 3-4 business days. On MLK Day no orders will be shipped.
0

PMS5003 "checksum failure"
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

PMS5003 "checksum failure"

by earthres on Sun Nov 28, 2021 10:34 pm

Can someone tell me what causes the "checksum failure" message when using the PMS5003 particulate sensor in "software serial" mode? (I'm using it with an UNO.) Is it possible to "reset" the sensor after such a message? Does the library for Adafruit's I2C version of this sensor (I haven't used it yet) provide a way to get past the checksum failure -- perhaps by automatically trying to read again?

earthres
 
Posts: 44
Joined: Fri May 28, 2021 10:48 am

Re: PMS5003 "checksum failure"

by adafruit_support_bill on Mon Nov 29, 2021 6:43 am

The sensor sends readings in a 32 byte packet with a 16 bit checksum. If there is an error in transmission, the checksum will fail. This can happen due to a loose connection or interference. You can try reading again. If the problem persists, check your connections and/or try to identify the source of interference.

adafruit_support_bill
 
Posts: 82867
Joined: Sat Feb 07, 2009 10:11 am

Re: PMS5003 "checksum failure"

by earthres on Mon Nov 29, 2021 4:33 pm

I understand what you're saying, but connections are what they are and I can't imagine what could be a source of interference that I would have in my residential office. I have used (a LOT!) your PMS5003 with its breadboard breakout board and short jumper wires to an "official" (made in Italy) UNO, and other versions where I've hard wired the three required connections -- 5V, GND, and TX -- to an UNO . I was initially suspicious that PMS5003 versions from different sources would behave poorly, but I haven't found that to be the case, as the checksum failure is no more or less likely with your or any other version of this device that I've used.
I wonder if the fault could be some kind of timing issue with the software serial implementation? And I also wonder if your I2C version of the PMS sampler (one of which I have on order right now) will behave any differently... If it gets rid of the checksum failures, it would certainly be worth the higher price!

earthres
 
Posts: 44
Joined: Fri May 28, 2021 10:48 am

Re: PMS5003 "checksum failure"

by adafruit_support_bill on Mon Nov 29, 2021 5:39 pm

We can only speculate based on the information provided. There are lots of potential EMI sources in a typical home office. Fluorescent lights used to be frequent sources of trouble - but many of the LED replacements are no better. However, if your wires are short, they should not be affected much.

Software serial is somewhat less robust than a hardware UART. This also depends on what else is going on in the code. Since it is an asynchronous protocol, interrupt contention can lead to dropped bits.

i2c tends to be more susceptible to cabling issues, but it is a synchronous protocol where the master controls the clock. So it is less likely to suffer from interrupt contention.

adafruit_support_bill
 
Posts: 82867
Joined: Sat Feb 07, 2009 10:11 am

Re: PMS5003 "checksum failure"

by earthres on Fri Dec 03, 2021 3:14 pm

I have tried the I2C PMSA0031 with a BME280 and HUZZAH32-ESP32 board and it works fine, with no checksum errors that I could see. So that's the good news! However, when i tried to add a small OLED -- yes, I admit it, it isn't an Adafruit OLED -- the code refuses to work because it can't see the PMSA0031. (The same physical layout, with the OLED still attached, works with code that's the same as what I've given here except with all references to an OLED display removed. Yes, I tested the I2C addresses for all three of these devices and of course they are different.
This isn't the first time I've had problems with multiple I2C devices that include an OLED display. Any thoughts as to what the problem might be, and how to fix it?
Oh, and BTW, I have no fluorescent lighting in my small home office, and only a small LED desk lamp that isn't even turned on during the day. So there's no EMI from lighting.


Code: Select all | TOGGLE FULL SIZE
// ESP32_BME280_PM, D. Brooks, December 2021
#include "Adafruit_PM25AQI.h"
Adafruit_PM25AQI aqi = Adafruit_PM25AQI();
#include "Adafruit_BME280.h"
Adafruit_BME280 bme;
#include "U8x8lib.h"
#include "Wire.h"
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
const int delayTime=2000;
float T,P,RH,PM10,PM25,PM100;
void setup() {
  Serial.begin(9600);
  u8x8.begin(); 
  if (!bme.begin()) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    delay(10); exit(0);
  }
  else Serial.println("Found BME280 sensor."); 
  u8x8.begin();
  u8x8.setFont(u8x8_font_chroma48medium8_r);
  if (! aqi.begin_I2C()) {      // connect to the sensor over I2C
   Serial.println("Could not find PM 2.5 sensor!");
   while (1) delay(10);
  }
  Serial.println("PM25 found!"); 
}
void loop() {
 
  T=bme.readTemperature(); delay(10); // just to make sure read is done...
  P=bme.readPressure(); delay(10);
  RH=bme.readHumidity(); delay(10);
  PM25_AQI_Data data;
  if (! aqi.read(&data)) {
    Serial.println("Could not read from AQI");
    delay(500);  // try again in a bit!
    return;
  }
  Serial.println("AQI reading success"); 
  PM10=data.pm10_env;  PM25=data.pm25_env;
  PM100=data.pm100_env;
  Serial.print("T, RH, P ");
  Serial.print(T,1); Serial.print(',');
  Serial.print(RH,1); Serial.print(',');
  Serial.print(P/100.,1); Serial.println();
  Serial.print(PM10,1); Serial.print(", ");
  Serial.print(PM25,1); Serial.print(", ");
  Serial.println(PM100,1);
  u8x8.setCursor(0,1);
  //u8x8.println("T, RH, P = ");
  u8x8.print(T,1); u8x8.println(" deg C ");
  u8x8.print(RH,1); u8x8.println(" %");
  u8x8.print(P/100.,1); u8x8.println(" mbar");
  u8x8.print(PM10,1);u8x8.print(' ');
  u8x8.print(PM25,1);u8x8.print(' ');
  u8x8.println(PM100,1);
  delay(delayTime);
  u8x8.clearDisplay();
}

earthres
 
Posts: 44
Joined: Fri May 28, 2021 10:48 am

Re: PMS5003 "checksum failure"

by adafruit_support_bill on Fri Dec 03, 2021 4:18 pm

If your OLED library needs to maintain a frame buffer in memory, you are probably looking at a memory problem. The UNO simply doesn't have much RAM to work with.
https://learn.adafruit.com/memories-of- ... ot-dot-dot

adafruit_support_bill
 
Posts: 82867
Joined: Sat Feb 07, 2009 10:11 am

Re: PMS5003 "checksum failure"

by earthres on Fri Dec 03, 2021 4:33 pm

Well, it's not an "old" OLED, but a relatively new 0.96" one from IZOKEE. I haven't had any problems using it with a couple of other I2C devices and the u8x8 text-only library on the same HUZZAH32-ESP32 circuit.

earthres
 
Posts: 44
Joined: Fri May 28, 2021 10:48 am

Re: PMS5003 "checksum failure"

by adafruit_support_bill on Fri Dec 03, 2021 9:19 pm

Well, it's not an "old" OLED,

Age is not the issue. How much RAM does it need?

adafruit_support_bill
 
Posts: 82867
Joined: Sat Feb 07, 2009 10:11 am

Re: PMS5003 "checksum failure"

by earthres on Sat Dec 04, 2021 11:56 am

OK. This seems like a "learnable" moment for me. How do I find the answer to your RAM question? What about your ID 326 0.96" OLED? Would I have the same problem? (I see that your documentation says it requires 1K of RAM.) I do know that the OLED I have is perfectly happy to run on I2C along with a BME280 and RTC, using a u8x8 text-only library, even on an UNO. Doesn't the HUZZAH32-ESP32 have a lot more available RAM than that??

earthres
 
Posts: 44
Joined: Fri May 28, 2021 10:48 am

Re: PMS5003 "checksum failure"

by adafruit_support_bill on Sat Dec 04, 2021 12:48 pm

How do I find the answer to your RAM question?

If there manufacturer's documentation doesn't specify, you can always measure the usage: https://learn.adafruit.com/memories-of- ... ree-memory
Make a simple sketch using just your display and the freeMemory() function: https://learn.adafruit.com/memories-of- ... m-370031-5
Compare the amount of free memory with and without your display code commented out.

I do know that the OLED I have is perfectly happy to run on I2C along with a BME280 and RTC, using a u8x8 text-only library, even on an UNO.

It only takes one byte over the line to crash the stack. The PMS library needs a 32 byte packet buffer on the heap, plus another one on the stack every time you do a read. Plus space for other local variables and the function call stack frame itself.

This is in addition to the 64 byte receive buffer for Serial, the Arduino runtime overhead and whatever other RAM is used directly or indirectly by the rest of your code.

The ATMEGA 32U4 is from the same processor family as the ATMEGA328 used on the UNO. That has 2.5K which may be sufficient to get you over the hump. The ATMEGA 2560 has 8K.

But there are lots of newer microcontroller chip designs with orders of magnitude more RAM to play with. The ESP32, ESP8266, Cortex M0 and M4 are some of the options. The ESP family can be a little finicky to work with. The Cortex M0 and M4 are a bit more friendly.

adafruit_support_bill
 
Posts: 82867
Joined: Sat Feb 07, 2009 10:11 am

Re: PMS5003 "checksum failure"

by earthres on Sat Dec 04, 2021 2:27 pm

Maybe I should try this a different way. Do you have a code example for using the serial PMS5003 and an I2C T/RH sensor with a HUZZAH32-ESP32 to send data to AdafruitIO? Then I wouldn't have to worry about the I2C problems. I know how to use the PMS5003 with software serial on an UNO, but how do I do this on the HUZZAH? software serial? hardware serial?

earthres
 
Posts: 44
Joined: Fri May 28, 2021 10:48 am

Re: PMS5003 "checksum failure"

by adafruit_support_bill on Sat Dec 04, 2021 2:48 pm

The software should be pretty much the same - except the software serial. The standard Arduino software serial lib does not support the ESP8266.

There is a version here that does. We do not have any experience with it: https://github.com/plerup/espsoftwareserial

adafruit_support_bill
 
Posts: 82867
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.