PMSA003 getting multiple readings instead of just one

I’m playing around with a PMSA003 particle sensor and trying to understand how exactly it works.
At first I connected the TX and RX to GPIO1 (TXD0) and GPIO3(RXD0), and this caused some problems so I moved them to GPIO 5 and 4.
When I set update_interval to 30s I get this “problem” where the reading get repeated 3/2 times is this normal? Setting it higher fix this behavior.

[11:30:39][D][pmsx003:234]: Got PM1.0 Concentration: 6 µg/m^3, PM2.5 Concentration 7 µg/m^3, PM10.0 Concentration: 7 µg/m^3
[11:30:39][D][sensor:093]: 'PM1.0 std': Sending state 6.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM2.5 std': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM10.0 std': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM1.0 amb': Sending state 6.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM2.5 amb': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM10 amb': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM0.3 per dL air': Sending state 891.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM0.5 per dL air': Sending state 265.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM1 per dL air': Sending state 38.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM2.5 per dL air': Sending state 0.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM5 per dL air': Sending state 0.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM10 per dL air': Sending state 0.00000 /dL with 0 decimals of accuracy
[11:30:39][D][pmsx003:234]: Got PM1.0 Concentration: 6 µg/m^3, PM2.5 Concentration 7 µg/m^3, PM10.0 Concentration: 7 µg/m^3
[11:30:39][D][sensor:093]: 'PM1.0 std': Sending state 6.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM2.5 std': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM10.0 std': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM1.0 amb': Sending state 6.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM2.5 amb': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM10 amb': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM0.3 per dL air': Sending state 891.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM0.5 per dL air': Sending state 265.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM1 per dL air': Sending state 38.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM2.5 per dL air': Sending state 0.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM5 per dL air': Sending state 0.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM10 per dL air': Sending state 0.00000 /dL with 0 decimals of accuracy
[11:30:39][D][pmsx003:234]: Got PM1.0 Concentration: 6 µg/m^3, PM2.5 Concentration 7 µg/m^3, PM10.0 Concentration: 7 µg/m^3
[11:30:39][D][sensor:093]: 'PM1.0 std': Sending state 6.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM2.5 std': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM10.0 std': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM1.0 amb': Sending state 6.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM2.5 amb': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM10 amb': Sending state 7.00000 µg/m³ with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM0.3 per dL air': Sending state 873.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM0.5 per dL air': Sending state 261.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM1 per dL air': Sending state 32.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM2.5 per dL air': Sending state 0.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM5 per dL air': Sending state 0.00000 /dL with 0 decimals of accuracy
[11:30:39][D][sensor:093]: 'PM10 per dL air': Sending state 0.00000 /dL with 0 decimals of accuracy
[11:30:39][W][component:237]: Component pmsx003.sensor took a long time for an operation (341 ms).
[11:30:39][W][component:238]: Components should block for at most 30 ms.

Thanks!

What config do you have?

Not exactly what you are asking, but here is a project that looking at it may add some insights. Sniffer Air Quality (AQI) Monitor using ESP32 + PMSA003 + BME680 - Bootloader Blog. Feel free to ignore if not helpful :slight_smile:

This is my current configuration:

i2c:
  sda: GPIO12
  scl: GPIO14
  scan: true
  frequency: 15kHz

uart:
  tx_pin: GPIO5
  rx_pin: GPIO4
  baud_rate: 9600  

sensor:
  - platform: ags10
    update_interval: 30s
    tvoc:
      name: TVOC
  - platform: pmsx003
    type: PMSX003
    update_interval: 60s
    pm_1_0_std:
      name: "PM1.0 std"
    pm_2_5_std:
      name: "PM2.5 std"
    pm_10_0_std:
      name: "PM10.0 std"
    pm_1_0:
      name: "PM1.0 amb"
    pm_2_5:
      name: "PM2.5 amb"
    pm_10_0:
      name: "PM10 amb"
    pm_0_3um:
      name: "PM0.3 per dL air"
    pm_0_5um:
      name: "PM0.5 per dL air"    
    pm_1_0um:
      name: "PM1 per dL air"  
    pm_2_5um:
      name: "PM2.5 per dL air"    
    pm_5_0um:
      name: "PM5 per dL air"    
    pm_10_0um:
      name: "PM10 per dL air"          
 

Using a update_interval >60s fix the issue.
I’m still trying to understand if setting a 30s interval shuts down the laser between the reading, in order to avoid spinning up and down the fan. But I guess the two are tied?
Thanks!

Nice project!

Did you find a datasheet for your sensor? They typically provide lower level details.

Reading the source code for the ESPHome side of things can sometimes shed some light too.
https://esphome.io/api/pmsx003_8h_source

Ok, my coding ability is quite limited so, probably, I missed something…
In the datasheets I found online, they speak about passive/active mode and sleep/wakeup.
After reading the pmsx003.cpp my guess on why I get multiple readings when I set a delay ≤ 30s is because it never enters inside this part of code:

if (this->update_interval_ > PMS_STABILISING_MS) {
    if (this->initialised_ == 0) {
      this->send_command_(PMS_CMD_AUTO_MANUAL, 0);
      this->send_command_(PMS_CMD_ON_STANDBY, 1);
      this->initialised_ = 1;

and the sensor remains in active mode ( 200-800ms refresh rate).

But I still haven’t found out if it is possible to power off the laser with the fan on.
In sleep mode, the fan and the laser are powered down.
When waken up, the fan spins up and the sensor can be set to active( default, the sensor spits out data continuously) or passive (sends data only when requested). But I couldn’t find out if the laser is powered off between the manual requests…

I contacted Plantower support and they said that the sensor is always working in the wake-up state, whether actively or passively reporting data.
So in summary:
You can’t control the fan and sensor individually. In passive mode, the laser is constantly on and you just control the data flow.
The reason you are getting a “burst” of reading when setting an update_interval<30s is code-related. Under that threshold, the sensor remains in the default active mode, so it pushes data as fast as it can when probed.

1 Like

i can’t believe Plantower told you this. Sensor mode and fan power can be controlled via serial commands

wait… really? where can I find this command? Unfortunately it isn’t mentioned in the datasheets I found online…

it is in the datasheet

for example look at this class

the fan of my pms stops and starts when i want (and i get a reading when i want)

It’s the same I already read. When you put it in standby mode the sensor get powered off but the fan too. You can’t keep the fan on and shut down the laser only… Or I’m missing something?