diff --git a/README.md b/README.md index 9d09ac6..e71212a 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,7 @@ This is yet another SDS011 library, this time completely non blocling. It does c ## Installation * For Arduino IDE: see [the Arduino Guide](https://www.arduino.cc/en/Guide/Libraries#toc4) - -~~For Platformio: see the [Platfomio guide](http://docs.platformio.org/en/latest/projectconf/section_env_library.html)~~ Not yet registered +* For Platformio: see the [Platfomio guide](http://docs.platformio.org/en/latest/projectconf/section_env_library.html) ## Usage diff --git a/library.json b/library.json index ed6429c..1ebb12e 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "SDS011", - "version": "0.0.1", + "version": "1.0.0", "keywords": "SDS011, dust, sensor, Arduino, ESP8266", "description": "Non blocking SDS011 sensor library for ESP8266", "homepage": "https://github.com/bertmelis/SDS011", diff --git a/library.properties b/library.properties index 48fbd20..32fef4a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SDS011 -version=0.0.1 +version=1.0.0 author=Bert Melis maintainer=Bert Melis sentence=Non blocking SDS011 sensor library for ESP8266 diff --git a/src/SDS011.cpp b/src/SDS011.cpp index 7b0d554..e108c5f 100644 --- a/src/SDS011.cpp +++ b/src/SDS011.cpp @@ -125,10 +125,12 @@ void SDS011::loop() { } else { // 2. check message type if (_rxBuff[1] == 0xC5) { // 3. response or data? - if (_onResponse) _onResponse(); // 4. signal response + if (_onResponse) _onResponse(_rxBuff[2], _rxBuff[3], _rxBuff[4]); // 4. signal response } else { - float pm2_5 = ((_rxBuff[3] * 256.0) + _rxBuff[2]) / 10.0; - float pm10 = ((_rxBuff[5] * 256.0) + _rxBuff[4]) / 10.0; + uint16_t pm2_5_raw = (_rxBuff[3] << 8) + _rxBuff[2]; + float pm2_5 = pm2_5_raw / 10.0; + uint16_t pm10_raw = (_rxBuff[5] << 8) + _rxBuff[4]; + float pm10 = pm10_raw / 10.0; if (_onData) _onData(pm2_5, pm10); } } diff --git a/src/SDS011.h b/src/SDS011.h index 066abae..cccb981 100644 --- a/src/SDS011.h +++ b/src/SDS011.h @@ -30,7 +30,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include typedef std::function onDataHandler; // pm2.5, pm10 -typedef std::function onResponseHandler; +typedef std::function onResponseHandler; typedef std::function onErrorHandler; class SDS011 {