Airgradient Pro Presoldered v3.7 integration with Home Assistant - Extending PMS5003 service life

Hi All,
I would like to extend the service life of PMS5003 by having it turn off and on automatically and I’ve got the Airgradient Pro Presoldered.
Could someone help me what code I need to insert so the module can shut off/on every x seconds.

Below is what I have.

# Airgradient Pro presoldered edition
# D1 mini v4.0.0 with usb c port
substitutions:
  devicename: "airgradient-pro"
  upper_devicename: "Airgradient Pro"

esphome:
  name: "${devicename}"
  # Automatically add the mac address to the name
  # so you can use a single firmware for all devices
  # name_add_mac_suffix: true
  platform: ESP8266
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: MASKED

wifi:
  networks:
  - ssid: MASKED
    password: MASKED
  reboot_timeout: 15min

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ${upper_devicename} Fallback Hotspot
    password: "MASKED"

switch:
  - platform: safe_mode
    name: "Flash Mode (Safe Mode)"

  - platform: restart
    name: "Airgradient Livingroom Restart"

captive_portal:

i2c:
  sda: D2
  scl: D1

font:
  - file: "font/Roboto-Light.ttf"
    id: opensans
    size: 12

display:
  - platform: ssd1306_i2c
    id: oled
    address: 0x3c
    rotation: 0°
    model: "SH1106 128x64"
    pages:
      - id: page1
        lambda: |-
          it.printf(0, 0, id(opensans), "CO2: %.0fppm", id(co2).state);
          it.printf(0, 17, id(opensans), "PM25: %.0f", id(pm25).state);
          it.printf(0, 32, id(opensans), "Humidity: %.0f", id(humidity).state);
          it.printf(0, 47, id(opensans), "Temperature: %.0fC", id(temp).state);
      - id: page2
        lambda: |-
          it.printf(0, 0, id(opensans), "PM10 : %.0f", id(pm10).state);
          it.printf(0, 10, id(opensans), "PM25 : %.0f", id(pm25).state);
          it.printf(0, 20, id(opensans), "PM100: %.0f", id(pm100).state);

# Maybe add a page later

interval:
  - interval: 5s
    then:
      - display.page.show_next: oled
      - component.update: oled

uart:
  - rx_pin: D5
    tx_pin: D6
    baud_rate: 9600
    id: uart1
    
  - rx_pin: D4
    tx_pin: D3
    baud_rate: 9600
    id: uart2

sensor:
  - platform: sht3xd
    temperature:
      id: temp
      name: ${upper_devicename} Temperature
    humidity:
      id: humidity
      name: ${upper_devicename} Humidity
    address: 0x44
    update_interval: 10s
    
  - platform: pmsx003
    type: PMSX003
    uart_id: uart1
    pm_1_0:
      id: pm10
      name: "Particulate Matter <1.0µm Concentration"
    pm_2_5:
      id: pm25
      name: "${upper_devicename} Particulate Matter <2.5µm Concentration"
    pm_10_0:
      id: pm100
      name: "Particulate Matter <10.0µm Concentration"
    update_interval: 30000ms
      
  - platform: senseair
    uart_id: uart2
    co2:
      id: co2
      name: "${upper_devicename} SenseAir CO2 Value"
    update_interval: 60s

You already did that yourself by putting in an update interval on the PMS5003 of 30sec. The sensor will go in standby in between measurements.

  • update_interval (Optional): Amount of time to wait between generating measurements. If this is longer than 30 seconds, and if tx_pin is set in the UART configuration, the fan will be spun down between measurements. Default to 0s (forward data as it’s coming in from the sensor).

But to really extend an interval of more than 2min is recommended. Mine is at 3min for example.

2 Likes

@Hendrik , thank you! I wasn’t sure if the “update_interval” would actually power off the sensor. I’m playing around with the time scale and it’s currently set for me to see if things are working.

Does the fan stop spinning in between readings? If not, then you are not really extending the life of the sensor as the fan is more likely to fail then the rest, and the sensor itself could get dirtier more quickly. I saw a couple methods to stop the fan, with one being in software and another using a GPIO that puts the sensor to sleep. I used the GPIO method and my fan stops spinning but now I am not 1000% certain I triple-checked behavior with the default setup. I use ESPHome on mine as I have it integrated with Home Assistant.

I’m also using ESPHome, can you share your code? When I get a chance I’ll check to see if the fans on mine powers down.