esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
420 stars 26 forks source link

Software commands (not using pin3) to put PMS5003 to sleep to exponentially extend sensor life #2033

Open alexruffell opened 1 year ago

alexruffell commented 1 year ago

Describe the problem you have/What new integration you would like

The PMS5003 sensor has a 3.5yr life span according to the datasheet. It can be extended by either putting the sensor to sleep via a high level signal on pin 3 (Set) or by sending a sleep command via the UART. The command can be sent via the code pasted below however it is not officially supported, and thus braindead easy to do, and it gives a warning related to the response from the sensor being shorter than expected when the sleep mode is changed.

Please describe your use case for this integration and alternatives you've tried:

This code (see uart.write parts) adds the ability to put to sleep and awake the sensor:

interval:
  - interval: 150s
    # Two-minute interval to extend the life span of the PMS5003 sensor
    then:
      - switch.turn_on: pms_switch
      - delay: 30s
      - switch.turn_off: pms_switch

# Source: https://github.com/airgradienthq/arduino/blob/master/AirGradient.cpp#L123
switch:
  - platform: template
    name: "PMS5003"
    id: pms_switch
    optimistic: true
    turn_on_action:
      - uart.write:
          id: pms5003_uart
          data: [0x42, 0x4D, 0xE4, 0x00, 0x01, 0x01, 0x74]
    turn_off_action:
      - uart.write:
          id: pms5003_uart
          data: [0x42, 0x4D, 0xE4, 0x00, 0x00, 0x01, 0x73]

While it works fine, there is a warning:

[W][pmsx003:108]: PMSX003 length 4 doesn't match. Are you using the correct PMSX003 type?

The thread speculates that it is simply due to ESPHome expecting more data than is sent for this command given it only supports receiving measurement data.

Source of code above: https://forum.airgradient.com/t/extending-the-life-span-of-the-pms5003-sensor/114/9

This post gives more insight on what data is sent back:

https://forum.airgradient.com/t/extending-the-life-span-of-the-pms5003-sensor/114/13

Additional context

The thread where I found the information in this FR is:

https://forum.airgradient.com/t/extending-the-life-span-of-the-pms5003-sensor/114

I claim absolutely no credits! I am only relaying this in hopes that someone will merge this into ESPHome for official support.

stas-sl commented 1 year ago

Isn't it already implemented here https://github.com/esphome/esphome/pull/3053 ?