pimoroni / pms5003-python

Python library for the PMS5003 particulate sensor
MIT License
51 stars 20 forks source link

ttyAMA0 and pin defaults #1

Closed bsimmo closed 4 years ago

bsimmo commented 5 years ago

Why are you using the hard set ttyAMA0 ?

def init(self, device='/dev/ttyAMA0', baudrate=9600, pin_enable=22, pin_reset=27):

If you use /dev/serial0 as per normal RPi serial setups then it should just work on whatever configuration the Pi is set for. The override can then specify an actual port if needed. Also there seems nothing in the readme to place the enable line and reset line on pins on 22 and 27 as the defaults.

Is there a need to use the full uart for the PMS5003 (there isn't for the similar PM2.5/10 sensor SDS011/SDS021 iirc or for GNSS devices) There is nothing in the readme saying I have to disable or switch over BlueTooth on the PiZero or 3 series Pi's.

Gadgetoid commented 5 years ago

This library was written primarily to support the PMS5003 connector on our Enviro+ board - https://github.com/pimoroni/enviroplus-python - which led all of the design choices. As long as it doesn't break compatibility with Enviro+ then I'm happy to tease this out into a generic library for the PMS5003 (or accept PRs to that end), but I didn't have time at the time.

In my experience, failing to use a full UART just results in receiving garbage in lieu of comprehensible serial communications. You'd think a miniUART would handle it, but from my own testing it doesn't. Am I doing something wrong?

bsimmo commented 5 years ago

If it is set via raspi-config (or the line placed in config.txt) then everything should happen in the background. Nothing else to set.

I don't have the pms5003 near me to double check thought. The pms7003 should also work with this (I think) That Enviro+ is a nice bit of work, not looked into it in detail, will have to have a proper read up on it

You do sell the sensor separately though. :-)

On Mon, 24 Jun 2019, 2:35 pm Philip Howard, notifications@github.com wrote:

This library was written primarily to support the PMS5003 connector on our Enviro+ board - https://github.com/pimoroni/enviroplus-python - which led all of the design choices. As long as it doesn't break compatibility with Enviro+ then I'm happy to tease this out into a generic library for the PMS5003 (or accept PRs to that end), but I didn't have time at the time.

In my experience, failing to use a full UART just results in receiving garbage in lieu of comprehensible serial communications. You'd think a miniUART would handle it, but from my own testing it doesn't. Am I doing something wrong?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pimoroni/pms5003-python/issues/1?email_source=notifications&email_token=ACYAXN47HFG3IOAI4NLVCQ3P4DESFA5CNFSM4H2ZC242YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYM6BZI#issuecomment-505012453, or mute the thread https://github.com/notifications/unsubscribe-auth/ACYAXNZJGF3N7QZPYFH3OZDP4DESFANCNFSM4H2ZC24Q .

kelsotowers commented 4 years ago

I'm trying to wire up a PMS5003 to a stand-alone Pi - no Enviro+ as I only want particulates and a BME680 for temp, humidity, pressure and air quality. I thought I was being daft and missing something until I found this thread.

Please can someone confirm that as bsimmo says - the python code library is written for 'enable' to be wired to pin 22 and 'reset' to be wired to pin 27 on the Pi? The remainder is obvious, I think.

Thanks!

Gadgetoid commented 4 years ago

It's worth noting that none of these things are set in stone, the arguments in __init__ are just the defaults. You can just as easily do:

pm = PMS5003(device="/dev/serial0", baudrate=9600, pin_enable=99, pin_reset=999)

For stand-alone users, however, it might be a good idea for the examples to mention this!