Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions sensors/SensorDSM501A.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ 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)*0.0283168/100/1000) * (0.08205*_temperature)/0.01));
}
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));
// sleep before the next read
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
Expand Down