From 06508b525ba532414c8f3f590b5b620b482ce9e5 Mon Sep 17 00:00:00 2001 From: user2684 Date: Sun, 16 Dec 2018 18:13:37 +0100 Subject: [PATCH 1/5] Not using ppvm --- sensors/SensorDSM501A.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensors/SensorDSM501A.h b/sensors/SensorDSM501A.h index 395f594e..08605e0a 100644 --- a/sensors/SensorDSM501A.h +++ b/sensors/SensorDSM501A.h @@ -55,7 +55,7 @@ class SensorDSM501A: public Sensor { void onLoop(Child* child) { if (child == children.get(1)) { // get PM 1.0 - density of particles over 1 µm. - child->setValue((int)((_getPM(_pin_10)*0.0283168/100/1000) * (0.08205*_temperature)/0.01)); + child->setValue((int)(_getPM(_pin_10)); } if (child == children.get(2)) { // get PM 2.5 density of particles over 2.5 µm. From 9161373da3c92e02aa9426f73397a79f2ae588e6 Mon Sep 17 00:00:00 2001 From: user2684 Date: Sun, 16 Dec 2018 18:17:00 +0100 Subject: [PATCH 2/5] Not reporting negative values --- sensors/SensorDSM501A.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/sensors/SensorDSM501A.h b/sensors/SensorDSM501A.h index 08605e0a..362d5010 100644 --- a/sensors/SensorDSM501A.h +++ b/sensors/SensorDSM501A.h @@ -53,14 +53,13 @@ class SensorDSM501A: public Sensor { // define what to do during loop void onLoop(Child* child) { - if (child == children.get(1)) { - // get PM 1.0 - density of particles over 1 µm. - child->setValue((int)(_getPM(_pin_10)); - } - if (child == children.get(2)) { - // get PM 2.5 density of particles over 2.5 µm. - child->setValue((int)_getPM(_pin_25)); - } + int ppm = -1; + // get PM 1.0 - density of particles over 1 µm. + if (child == children.get(1)) ppm = (int)(_getPM(_pin_10); + // get PM 2.5 density of particles over 2.5 µm. + if (child == children.get(2)) ppm = (int)(_getPM(_pin_25); + // set the value if positive (e.g. negative = invalid read) + if (ppm > 0) child->setValue(ppm); }; // return PM concentration From b3b9e4cf9c12d169eebf6999cb27e289ea6ecb49 Mon Sep 17 00:00:00 2001 From: user2684 Date: Sun, 16 Dec 2018 18:18:21 +0100 Subject: [PATCH 3/5] Sleep between reads --- sensors/SensorDSM501A.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sensors/SensorDSM501A.h b/sensors/SensorDSM501A.h index 362d5010..0cd6071d 100644 --- a/sensors/SensorDSM501A.h +++ b/sensors/SensorDSM501A.h @@ -56,6 +56,8 @@ class SensorDSM501A: public Sensor { int ppm = -1; // get PM 1.0 - density of particles over 1 µm. if (child == children.get(1)) ppm = (int)(_getPM(_pin_10); + // sleep before the next read + sleepOrWait(2000); // get PM 2.5 density of particles over 2.5 µm. if (child == children.get(2)) ppm = (int)(_getPM(_pin_25); // set the value if positive (e.g. negative = invalid read) From e29f2d4fac5d4c07801c35c30149bf62c7257b9d Mon Sep 17 00:00:00 2001 From: user2684 Date: Sun, 16 Dec 2018 19:02:21 +0100 Subject: [PATCH 4/5] Fixed compilation issues --- sensors/SensorDSM501A.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sensors/SensorDSM501A.h b/sensors/SensorDSM501A.h index 0cd6071d..3d47cfcc 100644 --- a/sensors/SensorDSM501A.h +++ b/sensors/SensorDSM501A.h @@ -55,11 +55,11 @@ class SensorDSM501A: public Sensor { void onLoop(Child* child) { int ppm = -1; // get PM 1.0 - density of particles over 1 µm. - if (child == children.get(1)) ppm = (int)(_getPM(_pin_10); + if (child == children.get(1)) ppm = (int)(_getPM(_pin_10)); // sleep before the next read - sleepOrWait(2000); + nodeManager.sleepOrWait(2000); // get PM 2.5 density of particles over 2.5 µm. - if (child == children.get(2)) ppm = (int)(_getPM(_pin_25); + if (child == children.get(2)) ppm = (int)(_getPM(_pin_25)); // set the value if positive (e.g. negative = invalid read) if (ppm > 0) child->setValue(ppm); }; From fe57fe8103f14acd9fc01ad32665c8d68d2341fe Mon Sep 17 00:00:00 2001 From: user2684 Date: Tue, 18 Dec 2018 23:39:30 +0100 Subject: [PATCH 5/5] Fixed debug output --- sensors/SensorDSM501A.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sensors/SensorDSM501A.h b/sensors/SensorDSM501A.h index 3d47cfcc..64e1177b 100644 --- a/sensors/SensorDSM501A.h +++ b/sensors/SensorDSM501A.h @@ -57,11 +57,12 @@ class SensorDSM501A: public Sensor { // get PM 1.0 - density of particles over 1 µm. if (child == children.get(1)) ppm = (int)(_getPM(_pin_10)); // sleep before the next read - nodeManager.sleepOrWait(2000); + nodeManager.sleepOrWait(5000); // get PM 2.5 density of particles over 2.5 µm. if (child == children.get(2)) ppm = (int)(_getPM(_pin_25)); // set the value if positive (e.g. negative = invalid read) if (ppm > 0) child->setValue(ppm); + else debug(PSTR("!" LOG_SENSOR "READ\n")); }; // return PM concentration