PMS5003 air quality sensor library
Re: PMS5003 air quality sensor library
Maybe I have to wait this afternoon?
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: PMS5003 air quality sensor library
Well that looks good. Do you get any other output after the 40 seconds it waits at start?
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: PMS5003 air quality sensor library
Yes, a lot!
first one: "
Got no available bytes
No response to wakeup command
wakeUp
wakeUp got lock
Sending command: 228,1,False,16000
waiting 40.0s
"
2nd one: "
----------------------------------------------------------
Setting to active mode while sleeping
----------------------------------------------------------
Got no available bytes
Sending command: 228,1,False,16000
waiting 40.0s
"
3 :"
Got no available bytes
No response to wakeup command
wakeUp
wakeUp got lock
Sending command: 228,1,False,16000
waiting 40.0s
"
4:
"
----------------------------------------------------------
Setting to passive mode whithout sleeping with 20s interval
----------------------------------------------------------
Got no available bytes
Sending command: 228,1,False,16000
waiting 40.0s
"
5:
Got no available bytes
No response to wakeup command
Resetting not responding device
No reset pin defined, can't reset
Shutting device down as it is not responding
"
6:
"
----------------------------------------------------------
Activating EcoMode, interval will be adapted to 60s
----------------------------------------------------------
"
And nothing more... for moment, until more than 60 sec...
Thanks a lot!
first one: "
Got no available bytes
No response to wakeup command
wakeUp
wakeUp got lock
Sending command: 228,1,False,16000
waiting 40.0s
"
2nd one: "
----------------------------------------------------------
Setting to active mode while sleeping
----------------------------------------------------------
Got no available bytes
Sending command: 228,1,False,16000
waiting 40.0s
"
3 :"
Got no available bytes
No response to wakeup command
wakeUp
wakeUp got lock
Sending command: 228,1,False,16000
waiting 40.0s
"
4:
"
----------------------------------------------------------
Setting to passive mode whithout sleeping with 20s interval
----------------------------------------------------------
Got no available bytes
Sending command: 228,1,False,16000
waiting 40.0s
"
5:
Got no available bytes
No response to wakeup command
Resetting not responding device
No reset pin defined, can't reset
Shutting device down as it is not responding
"
6:
"
----------------------------------------------------------
Activating EcoMode, interval will be adapted to 60s
----------------------------------------------------------
"
And nothing more... for moment, until more than 60 sec...
Thanks a lot!
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: PMS5003 air quality sensor library
Is your device connected correctly?Got no available bytes
No response to wakeup command
Resetting not responding device
No reset pin defined, can't reset
Shutting device down as it is not responding
Can you read something if you manually call uart.read()?
If both answers are yes then mabye uart.flush() needs a different workaround:
Code: Select all
if self._uart.any():
self._uart.read(self._uart.any())
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: PMS5003 air quality sensor library
I have connected :
rx-pms to tx-pyboard(X1)
tx-pms to rx-pyboard(X2)
gnd to gnd
vcc to v+
The "uart.read()"'s command return None. I have placed it just after the "uart = machine.UART(1, baudrate=9600)"'s command
I have reversed rx and tx connection without success.
I will test to change the flush command...
Thanks.
rx-pms to tx-pyboard(X1)
tx-pms to rx-pyboard(X2)
gnd to gnd
vcc to v+
The "uart.read()"'s command return None. I have placed it just after the "uart = machine.UART(1, baudrate=9600)"'s command
I have reversed rx and tx connection without success.
I will test to change the flush command...
Thanks.
Re: PMS5003 air quality sensor library
OK,
Sorry,
A simple mistake of me. I haven't change the pin correctly in my file...
Now I have this error:
Sorry,
A simple mistake of me. I haven't change the pin correctly in my file...
Now I have this error:
Code: Select all
>>> import pms5003_test
None
wakeUp
wakeUp got lock
Sending command: 228,1,False,16000
waiting 40.0s
readFrame False False
__read_frame
readFrame got: (2, 2, 3, 2, 2, 3, 687, 187, 20, 2, 0, 0, 38656, 722)
Got (2, 2, 3, 2, 2, 3, 687, 187, 20, 2, 0, 0, 38656, 722)
device woke up
setPassiveMode
setPassiveMode got lock
Sending command: 225,0,True,1000
readFrame False False
__read_frame
Received command response frame: [66, 77, 0, 4, 225, 0, 1, 116]
readFrame got: True
Got True
setPassiveMode done
wakeUp done
_read got lock
Sending command: 226,0,False,10000
readFrame False False
__read_frame
got no values
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pms5003_test.py", line 105, in <module>
File "pms5003_test.py", line 102, in start
File "/sd/lib/uasyncio/core.py", line 109, in run_forever
File "/sd/lib/pms/pms5003.py", line 354, in _read
File "/sd/lib/pms/pms5003.py", line 260, in _sendCommand
File "/sd/lib/pms/pms5003.py", line 412, in _read_frame
File "/sd/lib/pms/pms5003.py", line 451, in __read_frame
TypeError: object of type 'NoneType' has no len()
>>>
Re: PMS5003 air quality sensor library
Yo,
Same result with :
"if self._uart.any():
self._uart.read(self._uart.any())"
for replacing the flush's command...
Finally, It works, the frame contains values wich looks rights... No?
I have just to keep them in variables like "pms2.5 = frame[1]"
No?
Same result with :
"if self._uart.any():
self._uart.read(self._uart.any())"
for replacing the flush's command...
Finally, It works, the frame contains values wich looks rights... No?
I have just to keep them in variables like "pms2.5 = frame[1]"
No?
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: PMS5003 air quality sensor library
I tried figuring out why you see that error but from the code I have, it is impossible that this error occurs in that line.
Can you post the code in line 451 just to be sure we have the same file? (we probably do but I just don't see how it is possible that the variable "buffer" in that line is suddenly "None" instead of a list)
Also please share you pms5003_test file.
To read the values from the pm object you use:
The different values can be found in the documentation (the README.md)
Code: Select all
File "/sd/lib/pms/pms5003.py", line 451, in __read_frame
TypeError: object of type 'NoneType' has no len()
Also please share you pms5003_test file.
The frame looks good now. If you want to print the values use this:Finally, It works, the frame contains values wich looks rights... No?
I have just to keep them in variables like "pms2.5 = frame[1]"
No?
Code: Select all
pm.registerCallback(pm.print)
Code: Select all
pms25=pm.pm25_standard
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Re: PMS5003 air quality sensor library
Yop,
my 451 line : "if len(data) != preframe_len and len(data) > 0:"
That's great! I'm very happy that the pms5003 works!
Thank you very much.
My sister is an aerosol researcher, and she doesn't have a better precision!
It's amazing!
For example, a virus coud be bigger than 0.3 um. (the covid is not far (0.12)). Very, very interessant data comes from pms5003. The example with smoke cigarets is kind.
I will can use it and tease my sister!
Kevin, your are a chief!
All my respect.
my 451 line : "if len(data) != preframe_len and len(data) > 0:"
That's great! I'm very happy that the pms5003 works!
Thank you very much.
My sister is an aerosol researcher, and she doesn't have a better precision!
It's amazing!
For example, a virus coud be bigger than 0.3 um. (the covid is not far (0.12)). Very, very interessant data comes from pms5003. The example with smoke cigarets is kind.
I will can use it and tease my sister!
Kevin, your are a chief!
All my respect.
Last edited by IHOXOHI on Tue Sep 08, 2020 10:36 am, edited 1 time in total.
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: PMS5003 air quality sensor library
Ah of course, my bad. I forgot that the line number changed because of the workarounds for uart.flush()
Still strange that uart.read() would return "None" although the program waits until enough data is available in uart.any()..
But I added a workaround for that, hopefully that will help.
Try this file and let me know if it works correctly: https://github.com/kevinkk525/pms5003_m ... pms5003.py
I'm glad it works for you now!
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode