Raspberry Pi 4, Enviro+, PMS5003 - /dev/ttyAMA0

I’m new to Raspberry Pi4 and have an issue with PMS5003 sensor.

I bought Raspberry Pi4, Enviro+ and PMS5003 a few days ago. Although I was able to run all examples from GitHub - pimoroni/enviroplus-python: Python library for the Enviro+ environmental monitoring board (light.py, weather.py etc.), I’m still facing issues with running particulates.py. When I run particulates.py I have the following exception:


2023-12-10 12:26:49.325 INFO particulates.py - Print readings from the PMS5003 particulate sensor.

Press Ctrl+C to exit!

Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/serial/serialposix.py”, line 322, in open
self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: ‘/dev/ttyAMA0’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/raspberry/enviro+/enviroplus-python/examples/particulates.py”, line 18, in
pms5003 = PMS5003()
^^^^^^^^^
File “/home/raspberry/.local/lib/python3.11/site-packages/pms5003/init.py”, line 112, in init
self.setup()
File “/home/raspberry/.local/lib/python3.11/site-packages/pms5003/init.py”, line 118, in setup
self._serial = serial.Serial(self._device, baudrate=self._baudrate, timeout=4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3/dist-packages/serial/serialutil.py”, line 244, in init
self.open()
File “/usr/lib/python3/dist-packages/serial/serialposix.py”, line 325, in open
raise SerialException(msg.errno, “could not open port {}: {}”.format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyAMA0: [Errno 2] No such file or directory: ‘/dev/ttyAMA0’

It says that /dev/ttyAMA0 is missing. Have I misconfigured something? In addition, I can tell you that I observed that the sensor’s fan works when I turn on Raspberry, but it stops after running particulates.py.

Tech notes.
I updated Raspbian just after unpacking my Raspberry.
I use pms5003 == 0.0.5 and st7735 == 0.0.5.

Just FYI, if you put three backticks (`) before and after blocks of text it will format it as code, which makes it easier to read.

FileNotFoundError: [Errno 2] No such file or directory: ‘/dev/ttyAMA0’

So that means it can’t find the serial connection which the PMS5003 needs to work. If you’re sure the wiring is right, try running sudo rpi-config and going into the interface options to check that the serial is enabled.

Otherwise, try listing the contents of /dev (ls /dev/) and see what else is in there.

Thank you for letting me know about formatting code.

Actually, it seems that you inspired me to find a solution :) Although there is no /dev/ttyAMA0, there is /dev/serial0, so…
… I’ve created a link (sudo ln /dev/serial0 /dev/ttyAMA0), and it works ;)