Hello,
First of all, thank you for publishing this driver, I'm not used to working with code that provides such raw values like I get from the pms5003!
Just a note here, not necessarily an issue...
I want to use my pms5003 with a Raspberry Pi Pico, I assumed that your sample code was focussed on a Raspberry Pi based on the fact that you had referenced pins 25 and 26 for TX / RX which don't match the Pico pinout. Though, side note here is that for these values to be accepted on the Pico I had to reference the pins, like this:
uart = machine.UART(1, tx=machine.Pin(4), rx=machine.Pin(5), baudrate=9600)
Although as it happens, I can omit these values altogether:
uart = machine.UART(1, baudrate=9600)
I'm assuming that the Pico already knows the relevant pins for UART0 and UART1 and so doesn't need them spelling out. Just a guess though.
I was having an issue, however, getting a reading from the driver even after I'd seen the byte values coming in when simply reading the values from the UART like so:
from machine import UART
uart = UART( 1 , 9600 )
while True:
reading = uart.readline()
print( reading )
It was consistently timing out wen attempting to wake up the device. I managed to track this down to line 252 of pms5003.py:
if self._uart.any() >= frame_len:
uart.any(), on the Pico it seems, only ever seems to return 0 when no bytes are available and 1 when there are.
I updated this line to if self._uart.any() >= 1: and from then on I reliably get readings from the sensor.
Thought I'd post this here since a) it might be interesting, b) it might help anyone else with this issue trying to use a Pico and c) in case you had any comment on whether this was or was not a good idea or if there is in fact some difference with the Pico that means it only returns 1 here, as is suggested can happen in the mictopython docs:
Cheers!
Hello,
First of all, thank you for publishing this driver, I'm not used to working with code that provides such raw values like I get from the pms5003!
Just a note here, not necessarily an issue...
I want to use my pms5003 with a Raspberry Pi Pico, I assumed that your sample code was focussed on a Raspberry Pi based on the fact that you had referenced pins 25 and 26 for TX / RX which don't match the Pico pinout. Though, side note here is that for these values to be accepted on the Pico I had to reference the pins, like this:
uart = machine.UART(1, tx=machine.Pin(4), rx=machine.Pin(5), baudrate=9600)Although as it happens, I can omit these values altogether:
uart = machine.UART(1, baudrate=9600)I'm assuming that the Pico already knows the relevant pins for UART0 and UART1 and so doesn't need them spelling out. Just a guess though.
I was having an issue, however, getting a reading from the driver even after I'd seen the byte values coming in when simply reading the values from the UART like so:
It was consistently timing out wen attempting to wake up the device. I managed to track this down to line 252 of pms5003.py:
if self._uart.any() >= frame_len:uart.any(), on the Pico it seems, only ever seems to return0when no bytes are available and1when there are.I updated this line to
if self._uart.any() >= 1:and from then on I reliably get readings from the sensor.Thought I'd post this here since a) it might be interesting, b) it might help anyone else with this issue trying to use a Pico and c) in case you had any comment on whether this was or was not a good idea or if there is in fact some difference with the Pico that means it only returns 1 here, as is suggested can happen in the mictopython docs:
Cheers!