diff --git a/examples/all.py b/examples/all.py index 31cd81b..33f0fd1 100755 --- a/examples/all.py +++ b/examples/all.py @@ -14,30 +14,46 @@ # Configure the PMS5003 for Enviro+ # pins and ports may vary for your hardware! -# Default, try to auto-detect platform +# Default, assume Raspberry Pi compatible, running Raspberry Pi OS Bookworm pms5003 = PMS5003(device="/dev/ttyAMA0", baudrate=9600) # Raspberry Pi 4 (Raspberry Pi OS) +# # GPIO22 and GPIO27 are enable and reset for Raspberry Pi 4 # use "raspi-config" to enable serial, or add # "dtoverlay=uart0" to /boot/config.txt +# # pms5003 = PMS5003(device="/dev/ttyAMA0", baudrate=9600, pin_enable="GPIO22", pin_reset="GPIO27") # Raspberry Pi 5 (Raspberry Pi OS) -# PIN15 and PIN13 are enable and reset for Raspberry Pi 5 +# +# GPIO22 and GPIO27 are enable and reset for Raspberry Pi 5 +# On older versions of Bookworm these might be PIN15 and PIN13 # use "raspi-config" to enable serial, or add # "dtoverlay=uart0-pi5" to /boot/firmware/config.txt -# pms5003 = PMS5003(device="/dev/ttyAMA0", baudrate=9600, pin_enable="PIN15", pin_reset="PIN13") +# +# pms5003 = PMS5003(device="/dev/ttyAMA0", baudrate=9600, pin_enable="GPIO22", pin_reset="GPIO27") # ROCK 5B +# # Use "armbian-config" to enable rk3568-uart2-m0 # Disable console on ttyS2 with: # sudo systemctl stop serial-getty@ttyS2.service # sudo systemctl disable serial-getty@ttyS2.service # sudo systemctl mask serial-getty@ttyS2.service # add "console=display" to /boot/armbianEnv.txt +# # pms5003 = PMS5003(device="/dev/ttyS2", baudrate=9600, pin_enable="PIN_15", pin_reset="PIN_13") +# Other +# +# Use gpiod to request the pins you want, and pass those into PMS5003 as LineRequest, offset tuples. +# +# from pms5003 import OUTL, OUTH +# from gpiod import Chip +# lines = Chip.request_lines(consumer="PMS5003", config={22: OUTH, 27: OUTL}) +# pms5003 = PMS5003(device="/dev/ttyAMA0", baudrate=9600, pin_enable=(lines, 22), pin_reset=(lines, 27)) + try: while True: data = pms5003.read() diff --git a/examples/specific.py b/examples/specific.py index 4b46533..2ff0b1f 100755 --- a/examples/specific.py +++ b/examples/specific.py @@ -13,30 +13,47 @@ # Configure the PMS5003 for Enviro+ # pins and ports may vary for your hardware! -# Default, try to auto-detect platform +# Default, assume Raspberry Pi compatible, running Raspberry Pi OS Bookworm pms5003 = PMS5003(device="/dev/ttyAMA0", baudrate=9600) # Raspberry Pi 4 (Raspberry Pi OS) +# # GPIO22 and GPIO27 are enable and reset for Raspberry Pi 4 # use "raspi-config" to enable serial, or add # "dtoverlay=uart0" to /boot/config.txt +# # pms5003 = PMS5003(device="/dev/ttyAMA0", baudrate=9600, pin_enable="GPIO22", pin_reset="GPIO27") # Raspberry Pi 5 (Raspberry Pi OS) -# PIN15 and PIN13 are enable and reset for Raspberry Pi 5 +# +# GPIO22 and GPIO27 are enable and reset for Raspberry Pi 5 +# On older versions of Bookworm these might be PIN15 and PIN13 # use "raspi-config" to enable serial, or add # "dtoverlay=uart0-pi5" to /boot/firmware/config.txt -# pms5003 = PMS5003(device="/dev/ttyAMA0", baudrate=9600, pin_enable="PIN15", pin_reset="PIN13") +# +# pms5003 = PMS5003(device="/dev/ttyAMA0", baudrate=9600, pin_enable="GPIO22", pin_reset="GPIO27") # ROCK 5B +# # Use "armbian-config" to enable rk3568-uart2-m0 # Disable console on ttyS2 with: # sudo systemctl stop serial-getty@ttyS2.service # sudo systemctl disable serial-getty@ttyS2.service # sudo systemctl mask serial-getty@ttyS2.service # add "console=display" to /boot/armbianEnv.txt +# # pms5003 = PMS5003(device="/dev/ttyS2", baudrate=9600, pin_enable="PIN_15", pin_reset="PIN_13") +# Other +# +# Use gpiod to request the pins you want, and pass those into PMS5003 as LineRequest, offset tuples. +# +# from pms5003 import OUTL, OUTH +# from gpiod import Chip +# lines = Chip.request_lines(consumer="PMS5003", config={22: OUTH, 27: OUTL}) +# pms5003 = PMS5003(device="/dev/ttyAMA0", baudrate=9600, pin_enable=(lines, 22), pin_reset=(lines, 27)) + + try: while True: data = pms5003.read() diff --git a/pyproject.toml b/pyproject.toml index 990af4a..15dd52e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ classifiers = [ ] dependencies = [ "gpiod", - "gpiodevice", + "gpiodevice>=0.0.4", "pyserial" ]