sds011 final fixes for new lib

This commit is contained in:
cyberman54 2022-02-16 17:40:40 +01:00
parent f8d3780b2c
commit e4d6aea362
3 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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();

View File

@ -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