avaldebe/PyPMS

PMS5003T not recognized

pczolee opened this issue · 10 comments

Hello.

I try to use your program with a PMS5003T sensor. Unfortunately not recognized. Can you help me what should be the problem?

pms -m PMS5003T -s /dev/ttyAMA0 --debug info
DEBUG:pms:capture ? PMS5003T obs from /dev/ttyAMA0 every 60 secs

    Plantower PMS5003T sensor observations

    time                                    measurement time [seconds since epoch]
    raw01, raw25, raw10                     cf=1 PM estimates [μg/m3]
    pm01, pm25, pm10                        PM1.0, PM2.5, PM10 [μg/m3]
    n0_3, n0_5, n1_0, n2_5                  number concentrations over X.Y um [#/cm3]
    temp                                    temperature [°C]
    rhum                                    relative humidity [%]

    String formats: pm (default), raw, cf, num, atm, csv and header
pms -m PMS5003T -s /dev/ttyAMA0 --debug serial
DEBUG:pms:capture ? PMS5003T obs from /dev/ttyAMA0 every 60 secs
DEBUG:pms:open /dev/ttyAMA0
DEBUG:pms:wake PMS5003T
DEBUG:pms:buffer length: 47
DEBUG:pms:message hex: 1c000b00110011000b001100110742004d001c000a00100010000a0010001007bc024a0076000800d700e39a0004e0
ERROR:pms:Sensor is not PMS5003T

The sensor itself working, because I testing it with this:
https://github.com/pjq/rpi

./monitor.sh
start monitor pm2.5...
loop times 0
http://127.0.0.1:8080/api/weather
{"lat": 0, "date": "Mon Feb  1 13:44:06 2021", "alt": 0, "temperature": 21.8, "pm10": 16, "raw_data": "", "humidity": 22.9, "pm25_cf": 16, "location": "home", "pm10_cf": 16, "pm25": 16}

Thanks

DEBUG:pms:capture ? PMS5003T obs from /dev/ttyAMA0 every 60 secs
DEBUG:pms:open /dev/ttyAMA0
DEBUG:pms:wake PMS5003T
DEBUG:pms:buffer length: 47
DEBUG:pms:message hex: 1c000b00110011000b001100110742004d001c000a00100010000a0010001007bc024a0076000800d700e39a0004e0
ERROR:pms:Sensor is not PMS5003T

The buffer seems to be too long, as if your PMS5003T did not recognized the passive mode command.

Are you using the rpi's serial pins? Did you connect both RT and TX lines?

Yes I'm using both RX and TX (and nothing else, just the power is connected).

Maybe these help:

od /dev/ttyAMA0
0000000 000034 000012 000021 000023 000000 000000 000000 000000
0000020 000000 000000 000000 000000 000000 000000 000000 000000
*
0000100 000170 100200 000000 074370 100000 000200 100036 000170
0000120 174000 000170 100200 017000 074200 000000 074200 074000
0000140 100000 017000 074200 000000 074200 100000 000200 100036
0000160 000170 100000 000170 100200 100036 000170 174000 000170
0000200 100370 100036 000170 174000 000170 100200 100036 000170
0000220 174000 000170 100200 100036 000170 174000 000170 100200
0000240 100036 000170 174000 000170 100200 100036 000170 174000
od -Ax -tcx1 /dev/ttyAMA0
000000 034  \0  \f  \0 022  \0 023  \0  \0  \0  \0  \0  \0  \0  \0  \0
        1c  00  0c  00  12  00  13  00  00  00  00  00  00  00  00  00
000010  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
        00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
*
000040  \0  \0  \0 200 200  \0 200 200  \0  \0 200  \0 200 200  \0  \0
        00  00  00  80  80  00  80  80  00  00  80  00  80  80  00  00
000050 200   x 340  \0 370   x 200  \0 036 200   x  \0  \0 370   x  \0
        80  78  e0  00  f8  78  80  00  1e  80  78  00  00  f8  78  00
000060   x  \0 200  \0 036 200   x  \0  \0 370   x  \0 200 200  \0 200
        78  00  80  00  1e  80  78  00  00  f8  78  00  80  80  00  80
xxd /dev/ttyAMA0
00000000: 001e 8078 0000 78e0 0078 0042 004d 001c  ...x..x..x.B.M..
00000010: 0009 0011 0012 0009 0011 0012 0768 021a  .............h..
00000020: 007e 0006 00d9 00e3 9a00 0468 424d 001c  .~.........hBM..
00000030: 0009 0011 0012 0009 0011 0012 0768 021a  .............h..
00000040: 007e 0006 00d9 00e2 9a00 0467 424d 001c  .~.........gBM..
00000050: 000a 0011 1200 0a00 1100 1207 0000 0000  ................
00000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000090: 7800 7800 8000 8078 0078 8000 1e80 7800  x.x....x.x....x.

Can you send me a few lines of xxd -g1 -c32 /dev/ttyAMA0?

xxd -g1 -c32 /dev/ttyAMA0
00000000: 00 78 fe 80 78 00 00 78 e0 00 f8 00 78 00 e0 00 f8 00 78 00 f8 00 78 1e 80 78 00 00 78 e0 00 f8  .x..x..x....x.....x...x..x..x...
00000020: 00 00 1e 80 78 00 00 78 e0 00 f8 00 78 42 00 4d 00 1c 00 0a 00 10 00 11 00 0a 00 10 00 11 07 7a  ....x..x....xB.M...............z
00000040: 02 42 00 7c 00 04 00 db 00 e4 9a 00 04 9f 42 4d 00 1c 00 0a 00 10 11 00 0a 00 10 00 11 07 00 00  .B.|..........BM................
00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
00000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 80 80 00 1e 80 78 00 00 f8  ............................x...
000000a0: 78 00 00 1e 80 78 00 00 f8 78 00 78 00 80 00 1e 80 78 00 00 f8 78 00 78 00 80 00 1e 80 78 00 00  x....x...x.x.....x...x.x.....x..
000000c0: 00 80 00 80 80 80 00 1e 80 78 00 00 00 00 80 80 00 1e 80 78 00 00 00 00 80 00 1e 80 78 00 00 f8  .........x.........x........x...

I can not find a valid header/message on this hexdump.
Can you set the baud rate to 9600? I think the command is stty -F /dev/ttyAMA0 9600

Hmm, interesting...

stty -F /dev/ttyAMA0 9600
xxd -g1 -c32 /dev/ttyAMA0
00000000: 00 00 00 00 00 80 80 00 00 fe 00 80 80 00 00 fe 78 1e 80 78 00 00 80 80 00 00 1e 80 78 00 00 78  ................x..x........x..x
00000020: 00 00 00 00 1e 80 78 00 00 78 00 00 00 00 42 00 4d 00 1c 00 11 00 1c 00 1c 00 11 00 1c 00 1c 0b  ......x..x....B.M...............
00000040: af 03 73 00 c4 00 08 00 ca 00 e3 9a 00 05 80 42 4d 00 1c 00 12 00 1d 00 1d 00 12 00 1d 00 1d c8  ..s............BM...............
00000060: 00 08 00 ca 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
00000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 80 00 78 fe 00 78 fe 00 80 80 00 78 fe 00 78  ...................x..x.....x..x
000000a0: fe 78 80 80 00 80 00 00 80 00 1e 80 78 00 00 80 80 00 00 00 1e 80 78 00 00 80 80 00 00 1e 80 78  .x..........x.........x........x
000000c0: 00 00 80 80 00 00 1e 80 78 00 00 80 80 00 f8 f8 1e 80 78 00 00 80 80 00 f8 f8 1e 80 78 00 00 80  ........x.........x.........x...
000000e0: 80 00 f8 f8 1e 80 78 00 00 80 80 00 80 f8 1e 80 78 00 00 80 80 00 80 f8 1e 80 78 00 00 80 80 00  ......x.........x.........x.....
00000100: 80 f8 1e 80 78 00 00 80 80 00 80 f8 1e 80 78 00 00 80 80 00 80 f8 1e 80 78 00 00 80 80 00 80 f8  ....x.........x.........x.......

I found the problem:

pms -m PMS5003T -s /dev/ttyAMA0 --debug serial
DEBUG:pms:capture ? PMS5003T obs from /dev/ttyAMA0 every 60 secs
DEBUG:pms:open /dev/ttyAMA0
DEBUG:pms:wake PMS5003T
DEBUG:pms:buffer length: 40
DEBUG:pms:message hex: 424d001c0012001e00200012001d00200c9903b300da001400d200ec9a0005eb424d0004e1000174
DEBUG:pms:message hex: 424d0004e1000174
DEBUG:pms:message payload: (57600,)
DEBUG:pms:message hex: 
DEBUG:pms:message header: b''
DEBUG:pms:message hex: 424d001c000f00200023000f001f00230be203580104002000d200e99a000510
DEBUG:pms:message payload: (15, 32, 35, 15, 31, 35, 3042, 856, 260, 32, 210, 233, 39424)
2021-02-02 07:30:13: PM1 15.0, PM2.5 31.0, PM10 35.0 μg/m3

I had to remove the serial0 references from /boot/cmdline...

Thanks for your help.

Glad I was able to help.
Could you post the results of the following commannd line on #2?

pms -m PMS5003ST -n 10 -i 10 serial -f hexdump

I use sensor data captures on the project documentation and test suite

Of course, I edited the command (because of the different com port):

pms -m PMS5003T -n 10 -i 10 -s /dev/ttyAMA0 serial -f hexdump
00000000: 42 4d 00 1c 00 17 00 27 00 29 00 16 00 23 00 29 10 08 04 a9 01 16 00 0c 00 d4 00 e0 9a 00 04 aa  BM.....'.)...#.)................
00000020: 42 4d 00 1c 00 15 00 24 00 24 00 14 00 21 00 24 0d c8 04 1f 00 e4 00 0e 00 d4 00 e0 9a 00 05 99  BM.....$.$...!.$................
00000040: 42 4d 00 1c 00 15 00 25 00 26 00 14 00 22 00 26 0f 00 04 66 00 fa 00 16 00 d4 00 e0 9a 00 05 3e  BM.....%.&...".&...f...........>
00000060: 42 4d 00 1c 00 14 00 23 00 2a 00 13 00 20 00 2a 0e a6 04 37 01 06 00 1e 00 d4 00 df 9a 00 04 ca  BM.....#.*... .*...7............
00000080: 42 4d 00 1c 00 17 00 26 00 26 00 16 00 23 00 26 0e e8 04 62 01 1e 00 0e 00 d4 00 e0 9a 00 05 44  BM.....&.&...#.&...b...........D
000000a0: 42 4d 00 1c 00 16 00 25 00 27 00 15 00 22 00 27 0e fd 04 5a 01 20 00 14 00 d4 00 df 9a 00 05 56  BM.....%.'...".'...Z. .........V
000000c0: 42 4d 00 1c 00 16 00 24 00 2a 00 15 00 21 00 2a 0e af 04 56 01 1a 00 16 00 d4 00 df 9a 00 05 04  BM.....$.*...!.*...V............
000000e0: 42 4d 00 1c 00 17 00 25 00 2d 00 16 00 22 00 2d 0e fd 04 6f 01 24 00 16 00 d5 00 de 9a 00 05 7f  BM.....%.-...".-...o.$..........
00000100: 42 4d 00 1c 00 15 00 23 00 2c 00 14 00 20 00 2c 0e ca 04 5a 01 1e 00 18 00 d5 00 de 9a 00 05 29  BM.....#.,... .,...Z...........)
00000120: 42 4d 00 1c 00 14 00 22 00 2b 00 13 00 20 00 2b 0e 13 04 14 01 10 00 1e 00 d5 00 df 9a 00 04 20  BM.....".+... .+...............