From c545136c063754844f2dac3f86119aac09d982cc Mon Sep 17 00:00:00 2001 From: August Quint <49277349+AugustQu@users.noreply.github.com> Date: Tue, 21 Jan 2020 14:54:35 +0100 Subject: [PATCH] plus modifications for SDS011 --- src/sdcard.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/sdcard.cpp b/src/sdcard.cpp index 0633151f..8e45ea7c 100644 --- a/src/sdcard.cpp +++ b/src/sdcard.cpp @@ -6,6 +6,12 @@ static const char TAG[] = __FILE__; #include "sdcard.h" +#if (HAS_SDS011) +#include +// the results of the sensor: +extern float pm25; +extern float pm10; +#endif static bool useSDCard; @@ -35,7 +41,13 @@ void sdcardWriteData(uint16_t noWifi, uint16_t noBle) { sprintf(tempBuffer, "%02d:%02d:%02d,", hour(t), minute(t), second(t)); fileSDCard.print(tempBuffer); sprintf(tempBuffer, "%d,%d", noWifi, noBle); - fileSDCard.println(tempBuffer); + fileSDCard.print( tempBuffer); +#if (HAS_SDS011) + ESP_LOGD(TAG, "fine-dust-values: %5.1f,%4.1f", pm10, pm25); + sprintf(tempBuffer, ",%5.1f,%4.1f", pm10, pm25); + fileSDCard.print( tempBuffer); +#endif + fileSDCard.println( ); if (++counterWrites > 2) { // force writing to SD-card @@ -58,8 +70,12 @@ void createFile(void) { ESP_LOGD(TAG, "SD: file does not exist: opening"); fileSDCard = SD.open(bufferFilename, FILE_WRITE); if (fileSDCard) { - ESP_LOGD(TAG, "SD: name opended: <%s>", bufferFilename); - fileSDCard.println(SDCARD_FILE_HEADER); + ESP_LOGD(TAG, "SD: name opened: <%s>", bufferFilename); + fileSDCard.print( SDCARD_FILE_HEADER ); +#if (HAS_SDS011) + fileSDCard.print( SDCARD_FILE_HEADER_SDS011 ); +#endif + fileSDCard.println(); useSDCard = true; break; } @@ -68,4 +84,4 @@ void createFile(void) { return; } -#endif // (HAS_SDCARD) \ No newline at end of file +#endif // (HAS_SDCARD)