plus modifications for SDS011
This commit is contained in:
parent
04850fd5c7
commit
c545136c06
@ -6,6 +6,12 @@
|
|||||||
static const char TAG[] = __FILE__;
|
static const char TAG[] = __FILE__;
|
||||||
|
|
||||||
#include "sdcard.h"
|
#include "sdcard.h"
|
||||||
|
#if (HAS_SDS011)
|
||||||
|
#include <sds011read.h>
|
||||||
|
// the results of the sensor:
|
||||||
|
extern float pm25;
|
||||||
|
extern float pm10;
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool useSDCard;
|
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));
|
sprintf(tempBuffer, "%02d:%02d:%02d,", hour(t), minute(t), second(t));
|
||||||
fileSDCard.print(tempBuffer);
|
fileSDCard.print(tempBuffer);
|
||||||
sprintf(tempBuffer, "%d,%d", noWifi, noBle);
|
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) {
|
if (++counterWrites > 2) {
|
||||||
// force writing to SD-card
|
// force writing to SD-card
|
||||||
@ -58,8 +70,12 @@ void createFile(void) {
|
|||||||
ESP_LOGD(TAG, "SD: file does not exist: opening");
|
ESP_LOGD(TAG, "SD: file does not exist: opening");
|
||||||
fileSDCard = SD.open(bufferFilename, FILE_WRITE);
|
fileSDCard = SD.open(bufferFilename, FILE_WRITE);
|
||||||
if (fileSDCard) {
|
if (fileSDCard) {
|
||||||
ESP_LOGD(TAG, "SD: name opended: <%s>", bufferFilename);
|
ESP_LOGD(TAG, "SD: name opened: <%s>", bufferFilename);
|
||||||
fileSDCard.println(SDCARD_FILE_HEADER);
|
fileSDCard.print( SDCARD_FILE_HEADER );
|
||||||
|
#if (HAS_SDS011)
|
||||||
|
fileSDCard.print( SDCARD_FILE_HEADER_SDS011 );
|
||||||
|
#endif
|
||||||
|
fileSDCard.println();
|
||||||
useSDCard = true;
|
useSDCard = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -68,4 +84,4 @@ void createFile(void) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // (HAS_SDCARD)
|
#endif // (HAS_SDCARD)
|
||||||
|
Loading…
Reference in New Issue
Block a user