SOLVED!!
Well, not the noise, because still need to replace the sensor. BUT now changed the .INO file so only every 10 loops the SDS011 is switched on for about 30 seconds.
How?
- add following just before the „void loop()“ section:
// ---- SDS011 changes ----
static bool sdsIsOn = true;
uint8_t loopCount = 0;
uint8_t maxloopCount = 9;
// ---- SDS011 changes ----
- Add following just after the line „void loop()“
// SDS011 measurement loop.
// Only enable every 10th measurement
if (loopCount < maxloopCount) {
// Increase loopCount by one
loopCount++;
DEBUG(loopCount);
}
else {
// Reset loopCount and take measurement
loopCount = 0;
sdsIsOn = true;
DEBUG("Reset SDS loopCount and wakeup");
SDS.wakeup();
DEBUG("delay start");
delay(20000);
DEBUG("delay done");
}
// End of SDS011 measurement loop.
- then alter the „//------PM-----//“ section to look like this:
//-----PM-----//
#ifdef SDS011_CONNECTED
if (sdsIsOn)
{
DEBUG("Now in SDS011 Main measure loop");
uint8_t attempt = 0;
float pm10, pm25;
while (attempt < 5)
{
bool error = SDS.read(&pm25, &pm10);
if (!error)
{
addMeasurement(PM10SENSOR_ID, pm10);
addMeasurement(PM25SENSOR_ID, pm25);
break;
}
attempt++;
}
DEBUG("sleep SDS011 for a number of loops defined in maxloopCount");
SDS.sleep(); //put SDS011 into sleep mode, stopping fan as well
sdsIsOn = false; //define the status so next time no measurement is taken
}
- Then the applicable SDS011-select-serial.cpp file needs to be changed to make sure SDS.wakeup() actually works.
- This needs to be added:
static const byte WAKECMD[19] = {
0xAA, // head
0xB4, // command id
0x06, // data byte 1
0x01, // data byte 2 (set mode)
0x01, // data byte 3 (wake up)
0x00, // data byte 4
0x00, // data byte 5
0x00, // data byte 6
0x00, // data byte 7
0x00, // data byte 8
0x00, // data byte 9
0x00, // data byte 10
0x00, // data byte 11
0x00, // data byte 12
0x00, // data byte 13
0xFF, // data byte 14 (device id byte 1)
0xFF, // data byte 15 (device id byte 2)
0x06, // checksum
0xAB // tail
};
- And this needs to replace the wakeup section that is there:
// --------------------------------------------------------
// SDS011:wakeup
// --------------------------------------------------------
void SDS011::wakeup() {
for (uint8_t i = 0; i < 19; i++) {
sds_data.write(WAKECMD[i]);
}
sds_data.flush();
while (sds_data.available() > 0) {
sds_data.read();
}
}
Thanks @wschoch for giving the valuable hints into the right direction.
I also created an „issue“ in the Gidhub repository for OpenSenseMap repository (#426)