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.