lewapek / sds-dust-sensors-arduino-library

Library for Nova Fitness SDS dust sensors family (SDS011, SDS021)
MIT License
64 stars 19 forks source link

Library not working well with hardware serial #3

Closed mellbratt closed 6 years ago

mellbratt commented 6 years ago

Trying to use the library with Adafruit's Feather m0 LoRa, a SAMD based board that has several assignable hardware serial ports but doesn't play well with the software serial library. I've tried to make some adaptations but have gotten stuck. Any plans to update the library and accommodate streams that aren't software serial?

lewapek commented 6 years ago

@mellbratt HardwareSerial support should be merged soon in PR #4

lewapek commented 6 years ago

Done Release 1.2.0

mellbratt commented 6 years ago

Thank you for the super quick response!

If I may.. I haven't made a PR as I don't know if this is the correct way of solving my issues, let me know if I'm getting it right and I can provide one.

When verifying code in the Arduino IDE it stops and complains about the missing SoftwareSerial library. I have edited all the mentions of it to be placed inside `#ifndef _VARIANT_ARDUINOZERO

endif`

statements, and it now compiles correctly. Is this the way you'd like to deal with it, or is there a better way?

Cheers

lewapek commented 6 years ago

Hi, SoftwareSerial library may not be available for all boards. I think preprocessor directives are the correct way to make compiler happy however they always pollute the codebase... the challenge is to write as few #ifndef ... statements as possible, so the code remains clean. Feel free to open PR :)

proffalken commented 5 years ago

@mellbratt if you can put up a working copy of your code in a gist (gist.github.com) then I'd be happy to fork the repo, add you changes, submit the PR, and make sure you get full credit for it?

I'm stuck trying to connect my SDS011 to the SODAQ ExpLoRer and other ESP32-based boards for which SoftwareSerial doesn't exist, and none of the SDS011 libraries that I can find seem to support these boards!