diff --git a/src/cyclic.cpp b/src/cyclic.cpp index 67d21262..385f9afe 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -120,10 +120,8 @@ void doHousekeeping() { #if (HAS_SDS011) if (isSDS011Active) { - ESP_LOGD(TAG, "SDS011: go to sleep"); sds011_loop(); } else { - ESP_LOGD(TAG, "SDS011: wakeup"); sds011_wakeup(); } #endif diff --git a/src/sdcard.cpp b/src/sdcard.cpp index 72af507e..c8696bb1 100644 --- a/src/sdcard.cpp +++ b/src/sdcard.cpp @@ -82,7 +82,8 @@ void sdcardWriteData(uint16_t noWifi, uint16_t noBle, #endif #if (HAS_SDS011) sds011_store(&sds); - snprintf(tempBuffer, sizeof(tempBuffer), ",%5.1f,%4.1f", sds.pm10, sds.pm25); + snprintf(tempBuffer, sizeof(tempBuffer), ",%5.1f,%4.1f", sds.pm10 / 10, + sds.pm25 / 10); fileSDCard.print(tempBuffer); #endif fileSDCard.println(); diff --git a/src/sds011read.cpp b/src/sds011read.cpp index c8c754f3..b1f4d4b0 100644 --- a/src/sds011read.cpp +++ b/src/sds011read.cpp @@ -19,10 +19,9 @@ static float pm10 = 0.0, pm25 = 0.0; // init bool sds011_init() { sds.begin(9600, SERIAL_8N1, SDS_RX, SDS_TX); - String version = sds.queryFirmwareVersion().toString(); - ESP_LOGI(TAG, "SDS011 firmware version %s", version); + sds011_wakeup(); + ESP_LOGI(TAG, "SDS011: %s", sds.queryFirmwareVersion().toString().c_str()); sds.setQueryReportingMode(); - sds011_sleep(); // we do sleep/wakup by ourselves return true; } @@ -32,13 +31,14 @@ void sds011_loop() { if (isSDS011Active) { PmResult pm = sds.queryPm(); if (!pm.isOk()) { - ESP_LOGE(TAG, "SDS011 query error %s", pm.statusToString()); + ESP_LOGE(TAG, "SDS011: query error %s", pm.statusToString().c_str()); pm10 = pm25 = 0.0; } else { - ESP_LOGI(TAG, "SDS011: %s", pm.toString()); + ESP_LOGI(TAG, "SDS011: %s", pm.toString().c_str()); pm10 = pm.pm10; pm25 = pm.pm25; } + ESP_LOGD(TAG, "SDS011: go to sleep"); sds011_sleep(); } } @@ -60,6 +60,7 @@ void sds011_sleep(void) { void sds011_wakeup() { WorkingStateResult state = sds.wakeup(); isSDS011Active = state.isWorking(); + ESP_LOGD(TAG, "SDS011: %s", state.toString().c_str()); } #endif // HAS_SDS011