bertmelis / SDS011

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

Allow non-default serial port #5

Closed suhlig closed 3 years ago

suhlig commented 4 years ago

The ESP32 has three serial ports. This allows to connect the SDS011 to a port that is different from the default one, so that we can still print to the default serial port and see what's going on with the SDS011.

So far this was not possible because SDS011::setup calls Serial.begin with default args, which also means default pins.

This PR adds an overloaded SDS011::setup which accepts arbitrary rx and tx pins as additional parameters.

An alternative implementation would simply remove the Serial.begin call from SDS011::setup. I would actually prefer this, as it leaves setup to the caller. On the other hand, it would break existing clients, so I went with the approach in this PR.

I also added an example that showcases the new behaviour.

bertmelis commented 4 years ago

According Travis, the build fails on ESP8266. Should the extra method be guarded by #ifdef to limit this to ESP32?

suhlig commented 4 years ago

Ah, I overlooked that part. Yes, an #ifdef looks like a sensible way to solve that.

Just pushed a fixup commit.

suhlig commented 4 years ago

Travis status seems out of sync - the builds are green now.

suhlig commented 3 years ago

Hi @bertmelis any chance to merge this? Please note that the Travis checks are actually green; it seems just the reporting back to GH is broken somehow.

bertmelis commented 3 years ago

Sorry for the delay. Totally forgot about it.