avaldebe / PyPMS

Data acquisition and logging for Air Quality Sensors with UART interface
https://avaldebe.github.io/PyPMS/
MIT License
29 stars 8 forks source link

unreliably identifying the SPS30 sensor #25

Closed oylern closed 3 years ago

oylern commented 3 years ago

When running the pms command, it seems to have trouble reliably identifying my SPS30 sensor. I can run it back to back a few times until the sensor is identified correctly and gives me readings. Here is example where it failed twice and worked the third time:

root@raspberrypi:/home/pi# pms -m SPS30 -n 3 -i 3 -s /dev/ttyAMA0 --debug serial -f csv
DEBUG:pms:capture 3 SPS30 obs from /dev/ttyAMA0 every 3 secs
DEBUG:pms:open /dev/ttyAMA0
DEBUG:pms:wake SPS30
DEBUG:pms:buffer length: 55
DEBUG:pms:message hex: 7e00004300bc7e7e0003002841204c59413a57fe4147f7e9414ab18542862e7d5e429d0205429fc71f42a04c1642a064f03f2b2c584c7e
DEBUG:pms:message hex: 7e0003002841204c59413a57fe4147f7e9414ab18542862e7d5e429d0205429fc71f42a04c1642a064f03f2b2c584c
ERROR:pms:Sensor is not SPS30
root@raspberrypi:/home/pi# pms -m SPS30 -n 3 -i 3 -s /dev/ttyAMA0 --debug serial -f csv
DEBUG:pms:capture 3 SPS30 obs from /dev/ttyAMA0 every 3 secs
DEBUG:pms:open /dev/ttyAMA0
DEBUG:pms:wake SPS30
DEBUG:pms:buffer length: 55
DEBUG:pms:message hex: 7e00004300bc7e7e000300284122a280413d479c414b47ec414e14c742887d3103429f438842a21ae142a2a35b42a2bcc83f2714e3b57e
DEBUG:pms:message hex: 7e000300284122a280413d479c414b47ec414e14c742887d3103429f438842a21ae142a2a35b42a2bcc83f2714e3b5
ERROR:pms:Sensor is not SPS30
root@raspberrypi:/home/pi# pms -m SPS30 -n 3 -i 3 -s /dev/ttyAMA0 --debug serial -f csv
DEBUG:pms:capture 3 SPS30 obs from /dev/ttyAMA0 every 3 secs
DEBUG:pms:open /dev/ttyAMA0
DEBUG:pms:wake SPS30
DEBUG:pms:buffer length: 54
DEBUG:pms:message hex: 7e00004300bc7e7e0003002841243d73413ef673414cf3b7414fbff94289782742a0dd0242a3b4df42a43d5d42a456dc3f23c6b63f7e
DEBUG:pms:message hex: 7e0003002841243d73413ef673414cf3b7414fbff94289782742a0dd0242a3b4df42a43d5d42a456dc3f23c6b63f7e
DEBUG:pms:message payload: (10.265002250671387, 11.935168266296387, 12.809500694274902, 12.984368324279785, 68.73467254638672, 80.43165588378906, 81.85326385498047, 82.1198501586914, 82.16964721679688, 0.6397508382797241)
DEBUG:pms:message hex: 7e00030000fc7e
DEBUG:pms:message header: b'~\x00\x03\x00\x00'
DEBUG:pms:message hex: 7e00030028411d271d41368ea94143cf3f414675c0428397334299f243429ca4c7429d2635429d3e703f26a0730f7e
DEBUG:pms:message payload: (9.822049140930176, 11.409829139709473, 12.238097190856934, 12.40374755859375, 65.7953109741211, 76.9731674194336, 78.32183074951172, 78.57462310791016, 78.6219482421875, 0.6508857607841492)
time, pm01, pm25, pm04, pm10, n0_5, n1_0, n2_5, n4_0, n10_0, diam
1630355654, 9.8, 11.4, 12.2, 12.4, 65.80, 76.97, 78.32, 78.57, 78.62, 0.7
DEBUG:pms:message hex: 7e00030028411a411e4132fe45413fd7694142693442813a33429722e84299c197429a3f3b429a56d23f26ef40507e
DEBUG:pms:message payload: (9.640897750854492, 11.187077522277832, 11.990090370178223, 12.150684356689453, 64.6136703491211, 75.56817626953125, 76.87810516357422, 77.12349700927734, 77.16957092285156, 0.6520881652832031)
1630355657, 9.6, 11.2, 12.0, 12.2, 64.61, 75.57, 76.88, 77.12, 77.17, 0.7
DEBUG:pms:message hex: 7e00030028411ab0ca41334971413fffe441428ac64281a95542979869429a3159429aadd5429ac5463f27ae40017e
DEBUG:pms:message payload: (9.668161392211914, 11.205430030822754, 11.99997329711914, 12.158880233764648, 64.83072662353516, 75.79767608642578, 77.09638214111328, 77.33951568603516, 77.38529968261719, 0.6550025939941406)
1630355660, 9.7, 11.2, 12.0, 12.2, 64.83, 75.80, 77.10, 77.34, 77.39, 0.7
DEBUG:pms:sleep SPS30
DEBUG:pms:close /dev/ttyAMA0

Here is another time it errored where the initial response from the sensor was much shorter:

root@raspberry:/home/pi# pms -m SPS30 -n 3 -i 3 -s /dev/ttyAMA0 --debug serial -f csv
DEBUG:pms:capture 3 SPS30 obs from /dev/ttyAMA0 every 3 secs
DEBUG:pms:open /dev/ttyAMA0
DEBUG:pms:wake SPS30
DEBUG:pms:buffer length: 14
DEBUG:pms:message hex: 7e00000000ff7e7e00030000fc7e
ERROR:pms:Sensor is not SPS30

I should be able to work around this by capturing the error and looping the command until I get some kind of expected results, but maybe the SPS30 has been updated and has some new identifiers? I do see the buffer length was 54 when it worked vs the 55 and 14 seen previously. No idea what might be going on.

Hardware: Raspberry Pi model B rev 2 OS: Raspbian GNU/Linux 10 (buster) SPS30: attached to UART interface on pi (serial RX/TX, pins 8 and 10) and +5v and ground

avaldebe commented 3 years ago

Hi @oylern

Thanks for the bug report. It will take me some days to come up with a patch, but here is what I figured out from your debug output.

I do not have this sensor, so I wrote the module from the examples on the datasheet. There are some short messages that represent "message received" and "no data", which I did not accounted for. As far as I can tell, the relevant short messages are:

which can be seen on the rejected messages.

avaldebe commented 3 years ago

@oylern

I think that the last commits should solve the problem. Could you test this new version before I release it to pypi? You should be able to install this tar file pypms-0.6.1.tar.gz on your RPi with

pip install pypms-0.6.1.tar.gz
oylern commented 3 years ago

Thanks for the super fast efforts on this!

I loaded this version on my system and it seems to be catching the new error messages, but also throwing other errors sometimes:

root@raspberrypi:/home/pi# pms -m SPS30 -n 1 -i 1 -s /dev/ttyAMA0 serial -f pm
Traceback (most recent call last):
  File "/usr/local/bin/pms", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/typer/main.py", line 500, in wrapper
    return callback(**use_params)  # type: ignore
  File "/usr/local/lib/python3.7/dist-packages/pms/cli.py", line 84, in serial
    with reader:
  File "/usr/local/lib/python3.7/dist-packages/pms/core/reader.py", line 124, in __enter__
    if not self.sensor.check(buffer, "passive_mode"):  # pragma: no cover
  File "/usr/local/lib/python3.7/dist-packages/pms/core/sensor.py", line 81, in check
    self.Message.decode(buffer, self.command(command))
  File "/usr/local/lib/python3.7/dist-packages/pms/sensors/base.py", line 59, in decode
    return cls.unpack(message, header, length)[cls.data_records]  # type: ignore[call-overload]
  File "/usr/local/lib/python3.7/dist-packages/pms/sensors/sensirion/sps30.py", line 43, in unpack
    raise SensorWarmingUp("short message: no data")
pms.SensorWarmingUp: short message: no data
root@raspberrypi:/home/pi# pms -m SPS30 -n 1 -i 1 -s /dev/ttyAMA0 --debug serial -f pm
DEBUG:pms:capture 1 SPS30 obs from /dev/ttyAMA0 every 1 secs
DEBUG:pms:open /dev/ttyAMA0
DEBUG:pms:wake SPS30
DEBUG:pms:buffer length: 55
b"~\x00\x00C\x00\xbc~~\x00\x03\x00(@\xb0>\x98A\x16\xdf\x04AE\x8e\x97AN\xe4\xebA\xe8v\x8fB\x1e9\xe1B.\xe2\xe9B2'\x10B2\xa2\x18?n\xc6\x11\x8b~"
b"~\x00\x00C\x00\xbc~~\x00\x03\x00(@\xb0>\x98A\x16\xdf\x04AE\x8e\x97AN\xe4\xebA\xe8v\x8fB\x1e9\xe1B.\xe2\xe9B2'\x10B2\xa2\x18?n\xc6\x11\x8b~"
DEBUG:pms:message hex: 7e00004300bc7e7e0003002840b03e984116df0441458e97414ee4eb41e8768f421e39e1422ee2e9423227104232a2183f6ec6118b7e
b"~\x00\x03\x00(@\xb0>\x98A\x16\xdf\x04AE\x8e\x97AN\xe4\xebA\xe8v\x8fB\x1e9\xe1B.\xe2\xe9B2'\x10B2\xa2\x18?n\xc6\x11\x8b~"
DEBUG:pms:message hex: 7e0003002840b03e984116df0441458e97414ee4eb41e8768f421e39e1422ee2e9423227104232a2183f6ec6118b7e
DEBUG:pms:message payload: (5.507640838623047, 9.429447174072266, 12.347311973571777, 12.930888175964355, 29.057889938354492, 39.556522369384766, 43.72159194946289, 44.53814697265625, 44.658294677734375, 0.9327097535133362)
DEBUG:pms:short message: no data
b'~\x00\x03\x00(@\xae\x83$A\x15\x8a^AC\xe4\x03AM)$A\xe5\xfbLB\x1c\xa0-B-*>B0hXB0\xe2x?m\xacK\xab~'
b'~\x00\x03\x00(@\xae\x83$A\x15\x8a^AC\xe4\x03AM)$A\xe5\xfbLB\x1c\xa0-B-*>B0hXB0\xe2x?m\xacK\xab~'
DEBUG:pms:message hex: 7e0003002840ae832441158a5e4143e403414d292441e5fb4c421ca02d422d2a3e423068584230e2783f6dac4bab7e
DEBUG:pms:message payload: (5.453508377075195, 9.346281051635742, 12.24316692352295, 12.82254409790039, 28.747703552246094, 39.15642166137695, 43.29125213623047, 44.101898193359375, 44.221160888671875, 0.9284102320671082)
2021-08-31 07:38:22: PM1 5.5, PM2.5 9.3, PM4 12.2, PM10 12.8 μg/m3
DEBUG:pms:sleep SPS30
DEBUG:pms:close /dev/ttyAMA0
root@raspberrypi:/home/pi# pms -m SPS30 -n 1 -i 1 -s /dev/ttyAMA0 --debug serial -f pm
DEBUG:pms:capture 1 SPS30 obs from /dev/ttyAMA0 every 1 secs
DEBUG:pms:open /dev/ttyAMA0
DEBUG:pms:wake SPS30
DEBUG:pms:buffer length: 14
Traceback (most recent call last):
  File "/usr/local/bin/pms", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/typer/main.py", line 500, in wrapper
    return callback(**use_params)  # type: ignore
  File "/usr/local/lib/python3.7/dist-packages/pms/cli.py", line 84, in serial
    with reader:
  File "/usr/local/lib/python3.7/dist-packages/pms/core/reader.py", line 124, in __enter__
    if not self.sensor.check(buffer, "passive_mode"):  # pragma: no cover
  File "/usr/local/lib/python3.7/dist-packages/pms/core/sensor.py", line 81, in check
    self.Message.decode(buffer, self.command(command))
  File "/usr/local/lib/python3.7/dist-packages/pms/sensors/base.py", line 59, in decode
    return cls.unpack(message, header, length)[cls.data_records]  # type: ignore[call-overload]
  File "/usr/local/lib/python3.7/dist-packages/pms/sensors/sensirion/sps30.py", line 43, in unpack
    raise SensorWarmingUp("short message: no data")
pms.SensorWarmingUp: short message: no data
oylern commented 3 years ago

Turned off debug again and got another interesting output:

root@raspberrypi:/home/pi# pms -m SPS30 -n 1 -i 1 -s /dev/ttyAMA0 serial -f pm
b'~\x00\x00C\x00\xbc~~\x00\x03\x00(@\xc5\x8a\x83A9tzA{\x04lA\x84\x10\x9bA\xefj\x8bB,{\x94BC\xc0\xdeBHS\tBH\xfd@?q\x95E\xc2~'
b'~\x00\x00C\x00\xbc~~\x00\x03\x00(@\xc5\x8a\x83A9tzA{\x04lA\x84\x10\x9bA\xefj\x8bB,{\x94BC\xc0\xdeBHS\tBH\xfd@?q\x95E\xc2~'
b'~\x00\x03\x00(@\xc5\x8a\x83A9tzA{\x04lA\x84\x10\x9bA\xefj\x8bB,{\x94BC\xc0\xdeBHS\tBH\xfd@?q\x95E\xc2~'
b'~\x00\x03\x00(@\xb3\x89\xdcA)\xcd]Aff[Ar\x84\xfbA\xd7\xfb\xe5B\x1cd\x83B1\xe4\xbcB6\x1e\nB6\xbb7?t\xb0\xde\xb3~'
b'~\x00\x03\x00(@\xb3\x89\xdcA)\xcd]Aff[Ar\x84\xfbA\xd7\xfb\xe5B\x1cd\x83B1\xe4\xbcB6\x1e\nB6\xbb7?t\xb0\xde\xb3~'
2021-08-31 08:59:07: PM1 5.6, PM2.5 10.6, PM4 14.4, PM10 15.2 μg/m3
avaldebe commented 3 years ago

Turned off debug again and got another interesting output:

root@raspberrypi:/home/pi# pms -m SPS30 -n 1 -i 1 -s /dev/ttyAMA0 serial -f pm
b'~\x00\x00C\x00\xbc~~\x00\x03\x00(@\xc5\x8a\x83A9tzA{\x04lA\x84\x10\x9bA\xefj\x8bB,{\x94BC\xc0\xdeBHS\tBH\xfd@?q\x95E\xc2~'
b'~\x00\x00C\x00\xbc~~\x00\x03\x00(@\xc5\x8a\x83A9tzA{\x04lA\x84\x10\x9bA\xefj\x8bB,{\x94BC\xc0\xdeBHS\tBH\xfd@?q\x95E\xc2~'
b'~\x00\x03\x00(@\xc5\x8a\x83A9tzA{\x04lA\x84\x10\x9bA\xefj\x8bB,{\x94BC\xc0\xdeBHS\tBH\xfd@?q\x95E\xc2~'
b'~\x00\x03\x00(@\xb3\x89\xdcA)\xcd]Aff[Ar\x84\xfbA\xd7\xfb\xe5B\x1cd\x83B1\xe4\xbcB6\x1e\nB6\xbb7?t\xb0\xde\xb3~'
b'~\x00\x03\x00(@\xb3\x89\xdcA)\xcd]Aff[Ar\x84\xfbA\xd7\xfb\xe5B\x1cd\x83B1\xe4\xbcB6\x1e\nB6\xbb7?t\xb0\xde\xb3~'
2021-08-31 08:59:07: PM1 5.6, PM2.5 10.6, PM4 14.4, PM10 15.2 μg/m3

sorry, I left some of the debug prints

avaldebe commented 3 years ago

I loaded this version on my system and it seems to be catching the new error messages, but also throwing other errors sometimes: [...]

was not catching exceptions raised by the "short messages" on Sensor.check. I'll fix this and push a patch.

avaldebe commented 3 years ago

I loaded this version on my system and it seems to be catching the new error messages, but also throwing other errors sometimes: [...]

was not catching exceptions raised by the "short messages" on Sensor.check. I'll fix this and push a patch.

you should be able install this version with straight from github with

pip install git+https://github.com/avaldebe/PyPMS.git@27dbe0f
oylern commented 3 years ago

Looks like that branch (or tag) was deleted? pip tried anyway and hit a dependency error. I eventually went back to the standard install command, which looks like it recognizes 0.6.1 is available, but same output:

root@raspberrypi:/home/pi# python3 -m pip install git+https://github.com/avaldebe/PyPMS.git@27dbe0f
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/avaldebe/PyPMS.git@27dbe0f
  Cloning https://github.com/avaldebe/PyPMS.git (to revision 27dbe0f) to /tmp/pip-req-build-rbdpmlaj
  Did not find branch or tag '27dbe0f', assuming revision or ref.
  Installing build dependencies ... done
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.7/tokenize.py", line 447, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-rbdpmlaj/setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-rbdpmlaj/
root@raspberrypi:/home/pi# pip3 install git+https://github.com/avaldebe/PyPMS.git
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/avaldebe/PyPMS.git
  Cloning https://github.com/avaldebe/PyPMS.git to /tmp/pip-req-build-o2p__fbo
  Installing build dependencies ... done
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.7/tokenize.py", line 447, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-o2p__fbo/setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-o2p__fbo/
root@raspberrypi:/home/pi# python3 -m pip install pypms
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pypms in /usr/local/lib/python3.7/dist-packages (0.6.1)
Requirement already satisfied: typing-extensions>=3.10; python_version >= "3.6" and python_version < "3.8" in /usr/local/lib/python3.7/dist-packages (from pypms) (3.10.0.2)
Requirement already satisfied: importlib-metadata>=3.6; python_version >= "3.6" and python_version < "3.10" in /usr/local/lib/python3.7/dist-packages (from pypms) (4.8.1)
Requirement already satisfied: pyserial>=3.0 in /usr/local/lib/python3.7/dist-packages (from pypms) (3.5)
Requirement already satisfied: typer>=0.3 in /usr/local/lib/python3.7/dist-packages (from pypms) (0.4.0)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata>=3.6; python_version >= "3.6" and python_version < "3.10"->pypms) (3.5.0)
Requirement already satisfied: click<9.0.0,>=7.1.1 in /usr/local/lib/python3.7/dist-packages (from typer>=0.3->pypms) (8.0.1)
root@raspberrypi:/home/pi# pms -m SPS30 -n 1 -i 1 -s /dev/ttyAMA0 serial -f pm
Traceback (most recent call last):
  File "/usr/local/bin/pms", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/typer/main.py", line 500, in wrapper
    return callback(**use_params)  # type: ignore
  File "/usr/local/lib/python3.7/dist-packages/pms/cli.py", line 84, in serial
    with reader:
  File "/usr/local/lib/python3.7/dist-packages/pms/core/reader.py", line 124, in __enter__
    if not self.sensor.check(buffer, "passive_mode"):  # pragma: no cover
  File "/usr/local/lib/python3.7/dist-packages/pms/core/sensor.py", line 81, in check
    self.Message.decode(buffer, self.command(command))
  File "/usr/local/lib/python3.7/dist-packages/pms/sensors/base.py", line 59, in decode
    return cls.unpack(message, header, length)[cls.data_records]  # type: ignore[call-overload]
  File "/usr/local/lib/python3.7/dist-packages/pms/sensors/sensirion/sps30.py", line 43, in unpack
    raise SensorWarmingUp("short message: no data")
pms.SensorWarmingUp: short message: no data
root@raspberrypi:/home/pi# pms -m SPS30 -n 1 -i 1 -s /dev/ttyAMA0 serial -f pm
b'~\x00\x00C\x00\xbc~~\x00\x03\x00(@\xb1\x1e\x13A!\x87\xf1AXx}Acu_A\xdc\xcduB\x1c\x0f\xf4B/\x97}B3l\xffB3\xfc:?j\x98}D~'
b'~\x00\x00C\x00\xbc~~\x00\x03\x00(@\xb1\x1e\x13A!\x87\xf1AXx}Acu_A\xdc\xcduB\x1c\x0f\xf4B/\x97}B3l\xffB3\xfc:?j\x98}D~'
b'~\x00\x03\x00(@\xb1\x1e\x13A!\x87\xf1AXx}Acu_A\xdc\xcduB\x1c\x0f\xf4B/\x97}B3l\xffB3\xfc:?j\x98}D~'
b'~\x00\x03\x00(@\xab\x14\xe6A\x1b\xb2\xd3AP\x80(A[\x0f\x9eA\xd5\xb3\x9dB\x16\xd7iB)\x9c\xfbB-L_B-\xd6\x14?j\x96X\x82~'
b'~\x00\x03\x00(@\xab\x14\xe6A\x1b\xb2\xd3AP\x80(A[\x0f\x9eA\xd5\xb3\x9dB\x16\xd7iB)\x9c\xfbB-L_B-\xd6\x14?j\x96X\x82~'
2021-09-01 08:56:44: PM1 5.3, PM2.5 9.7, PM4 13.0, PM10 13.7 μg/m3
avaldebe commented 3 years ago

It looks like pip did not install the version from github, most likely because it has the same version number that the one I asked to install earlier.

I hope this command works.

pip install --force-reinstall git+https://github.com/avaldebe/PyPMS.git@54f5fe4

PS: sorry for the inconvenience

oylern commented 3 years ago

No worries at all! Thank you for working on the fix. :)

I ran into the same problem as before initially, uninstalled pypms, but then still couldn't install it again. Turns out I needed to upgrade pip to a newer version than what was shipped with Raspbian (pip3 install --upgrade pip). Once I did that, I could install pypms from git successfully. Now it works perfectly. Thanks again!

root@raspberrypi:/home/pi# pms -m SPS30 -n 1 -i 1 -s /dev/ttyAMA0 serial -f pm
2021-09-02 09:25:42: PM1 23.8, PM2.5 26.2, PM4 27.0, PM10 27.2 μg/m3
avaldebe commented 3 years ago

Hi @oylern

I'm glad the fix worked. Would you be so kind to contribute the output of the following command? I'll use the data capture on the docs and the test suite

pms -m SPS30 -n 10 -i 10 serial -f hexdump
oylern commented 3 years ago

Happy to. Here you go-

pi@raspberrypi:~ $ pms -m SPS30 -n 10 -i 10 -s /dev/ttyAMA0 serial -f hexdump
00000000: 7e 00 03 00 28 40 a7 83 20 41 17 77 bb 41 4a 5f 83 41 54 8d dd 41 d2 83 3e 42 7d 33 fc 85 42 26 17 22 42 29 a4 d9 42 2a 29 bc 3f 55 b7 e7 9e 7e  ....(@.. A.w.AJ_.AT..A..>B}3..B&."B)..B*).?U....
0000002f: 7e 00 03 00 28 40 b9 c6 7f 41 03 6c 8b 41 1e 4a e2 41 23 aa 92 42 0c 5b 7c 42 2e fd ba 42 38 ca b3 42 3a b2 c9 42 3a fd e9 3f 4a 10 25 d6 7e  ....(@...A.l.A.J.A#..B.[|B...B8..B:..B:..?J.%..
00000064: 7e 00 03 00 28 40 df 03 da 41 7d 31 62 ae 41 27 9e 32 41 2c 10 7d 5e 42 30 7d 5e d3 42 55 c0 4c 42 5e 09 08 42 5f a2 8a 42 5f e4 43 3f 40 fa 1f ff 7e  ....(@...A}1b.A'.2A,.}^B0}^.BU.LB^..B_..B_.C?@....
00000090: 7e 00 03 00 28 40 fa 9f ee 41 1e 6a 7d 33 41 33 60 81 41 37 91 cd 42 49 8e c8 42 71 b1 18 42 79 9a b4 42 7b 20 1b 42 7b 60 21 3f 3c a4 c4 87 7e  ....(@...A.j}3A3`.A7..BI..Bq..By..B{ .B{`!?<....
000000c0: 7e 00 03 00 28 41 05 1c 4c 41 27 8b 14 41 3d 38 59 41 41 8e 35 42 56 92 6c 42 80 79 7c 42 84 93 12 42 85 5c b2 42 85 7d 5d fb 3f 3e 67 ea 31 7e  ....(A..LA'..A=8YAA.5BV.lB.y|B...B.\.B.}].?>g.1.
000000f5: 7e 00 03 00 28 41 03 9f 9e 41 23 7d 5e 0b 41 37 29 dc 41 3b 18 f8 42 55 95 4a 42 7d 5e ba 00 42 83 1c 73 42 83 d4 4c 42 83 f3 10 3f 3e 00 79 76 7e  ....(A...A#}^.A7).A;..BU.JB}^..B..sB..LB...?>.yv.
00000120: 7e 00 03 00 28 41 06 b1 47 41 26 09 7d 5d 41 39 24 19 41 3c f6 37 42 5b 61 d6 42 82 85 77 42 86 2d ad 42 86 e0 ca 42 86 ff 03 3f 3d 19 e5 5b 7e  ....(A..GA&.}]A9$.A<.7B[a.B..wB.-.B...B...?=..[.
00000149: 7e 00 03 00 28 41 07 d4 61 41 26 1c 2a 41 38 4c cf 41 3b f0 1a 42 5e 17 d0 42 83 d2 21 42 87 52 70 42 87 fd 97 42 88 1a c2 3f 3e 47 c7 38 7e  ....(A..aA&.*A8L.A;..B^..B..!B.RpB...B...?>G.8.
00000178: 7e 00 03 00 28 41 0c 43 87 41 2b 1e da 41 3d 92 1e 41 41 42 bc 42 65 9c 10 42 88 2f 76 42 8b be 32 42 8c 6c 00 42 8c 89 b8 3f 3e 5a 83 89 7e  ....(A.C.A+..A=..AAB.Be..B./vB..2B.l.B...?>Z...
000001a7: 7e 00 03 00 28 41 07 9f e5 41 24 a7 bf 41 35 d7 db 41 39 47 db 42 5e 89 35 42 83 cd 07 42 87 20 a7 42 87 c2 f8 42 87 de e9 3f 3d be a6 ff 7e  ....(A...A$..A5..A9G.B^.5B...B. .B...B...?=....