Skip to content

Commit c1578b8

Browse files
committed
fix parsing
1 parent 8580b83 commit c1578b8

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ This is yet another SDS011 library, this time completely non blocling. It does c
1010
## Installation
1111

1212
* For Arduino IDE: see [the Arduino Guide](https://www.arduino.cc/en/Guide/Libraries#toc4)
13-
14-
~~For Platformio: see the [Platfomio guide](http://docs.platformio.org/en/latest/projectconf/section_env_library.html)~~ Not yet registered
13+
* For Platformio: see the [Platfomio guide](http://docs.platformio.org/en/latest/projectconf/section_env_library.html)
1514

1615
## Usage
1716

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SDS011",
3-
"version": "0.0.1",
3+
"version": "1.0.0",
44
"keywords": "SDS011, dust, sensor, Arduino, ESP8266",
55
"description": "Non blocking SDS011 sensor library for ESP8266",
66
"homepage": "https://github.com/bertmelis/SDS011",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SDS011
2-
version=0.0.1
2+
version=1.0.0
33
author=Bert Melis
44
maintainer=Bert Melis
55
sentence=Non blocking SDS011 sensor library for ESP8266

src/SDS011.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ void SDS011::loop() {
125125
} else {
126126
// 2. check message type
127127
if (_rxBuff[1] == 0xC5) { // 3. response or data?
128-
if (_onResponse) _onResponse(); // 4. signal response
128+
if (_onResponse) _onResponse(_rxBuff[2], _rxBuff[3], _rxBuff[4]); // 4. signal response
129129
} else {
130-
float pm2_5 = ((_rxBuff[3] * 256.0) + _rxBuff[2]) / 10.0;
131-
float pm10 = ((_rxBuff[5] * 256.0) + _rxBuff[4]) / 10.0;
130+
uint16_t pm2_5_raw = (_rxBuff[3] << 8) + _rxBuff[2];
131+
float pm2_5 = pm2_5_raw / 10.0;
132+
uint16_t pm10_raw = (_rxBuff[5] << 8) + _rxBuff[4];
133+
float pm10 = pm10_raw / 10.0;
132134
if (_onData) _onData(pm2_5, pm10);
133135
}
134136
}

src/SDS011.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3030
#include <Arduino.h>
3131

3232
typedef std::function<void(float, float)> onDataHandler; // pm2.5, pm10
33-
typedef std::function<void(void)> onResponseHandler;
33+
typedef std::function<void(uint8_t, uint8_t, uint8_t)> onResponseHandler;
3434
typedef std::function<void(int)> onErrorHandler;
3535

3636
class SDS011 {

0 commit comments

Comments
 (0)