bertmelis / SDS011

Non blocking SDS011 sensor library for ESP8266
MIT License
15 stars 8 forks source link

improvement? Software serial #4

Closed ubergeekseven closed 4 years ago

ubergeekseven commented 4 years ago

I have had so much trouble with this sensor and the esp8266. esp32 works and then I have more issues in other areas with that device. Specifically with my home automation setup.

Could you add software serial or maybe hint to how I could use it instead or hardware? I have successfully been able to use software serial with the espsoftwareserial library and the sdsdustsensor library. Allowing serial debugging while I build out the code.

The problem is that the sdsdustsensor library is blocking the entire time it sleeps the sds sensor. I find your library and it seems to be the godsend I am after. I just cannot understand how to add a different port, softwareserial port, to the example myself.

I looked through the library to see the references used and I cannot figure out how to modify it so that I can use something other than hardware serial.

can I somehow change the sds011.setup line to use softwareserial?

bertmelis commented 4 years ago

Try this: https://github.com/bertmelis/SDS011/tree/softwareserial

Let me know if it works for you. I'll update master branch.

ubergeekseven commented 4 years ago

Sorry for asking you to do this and then not responding. I just now saw the reply. I downloaded it and tested it. It compiles and uploads and starts but, I have tried out so many libraries that my setup is dirty now. I modified several other libraries to get my setup working and do not want to change things out until I clean up my workspace. I think I have some libraries with the same names as what is being used. I did end up getting everything to work using https://github.com/plerup/espsoftwareserial and https://github.com/lewapek/sds-dust-sensors-arduino-library. These are both in the arduino ide but, the ones in the ide are not the latest. After modifying them to use different include names, I have everything working. I do appreciate you putting in the time to modify your library. Hopefully other people can benefit from it.

LarsMichelsen commented 2 years ago

I just played around a bit with your library and used the changes from your softwareserial branch with esp8266 and communication has worked as expected. Loaded it into platformio using:

lib_deps =
        SDS011=https://github.com/bertmelis/SDS011/archive/refs/heads/softwareserial.zip