PMS5003 Laser lifetime
Posted: Fri 26 Aug 2022 1:52 pm
For any of you that have been using the PMS5003 in a homebuilt set up with your own code I wanted to show a possible upgrade to the code to extend the life of the laser. Basically it means disabling the unit for a couple of minutes and then re enabling it. It is not likley that the air quality changes significantly in that time frame but the code can be adjusted if you are in a significantly changing environment. (This is not my idea but adapted from another forum suggestion for arduino code)
I have been using the code pointed to by Pi Hut.
On my system the library module is stored in /usr/local/lib/python3.9/dist_packages/pms5003 in file _init_py
and then in my own python script where I read the PMS5003 I have :
This seems to work for me as the pms5003.sleep() call does stop readings being read. I tested that by commenting out the awake call. This resulted in a Timeout error.
I also had to connect the "SET" pin of the PMS5003 to GPIO22 (pin 15) on the Raspberry Pi board.
Reference:
Hope this is of use to someone.
I have been using the code pointed to by Pi Hut.
Code: Select all
https://thepihut.com/products/pms5003-particulate-matter-sensor-with-cable
On my system the library module is stored in /usr/local/lib/python3.9/dist_packages/pms5003 in file _init_py
Code: Select all
I have added the following after the def reset(self): code
# In library module _init_py
....
def sleep(self):
time.sleep(0.1)
GPIO.output(self._pin_reset, GPIO.LOW)
self._serial.flushInput()
time.sleep(0.1)
def awake(self):
time.sleep(0.1)
GPIO.output(self._pin_reset, GPIO.HIGH)
time.sleep(0.1)
.....
Code: Select all
# In python reading code
........
data = pms5003.read()
pms5003.sleep() # put in low power mode
time.sleep(90) # delay as long as you want
pms5003.awake()
time.sleep(30) # wait to allow to stabilise (I believe 30secs is recommended)
......
I also had to connect the "SET" pin of the PMS5003 to GPIO22 (pin 15) on the Raspberry Pi board.
Reference:
Code: Select all
https://forum.airgradient.com/t/extending-the-life-span-of-the-pms5003-sensor/114
Hope this is of use to someone.