Merge pull request #848 from cyberman54/joseph

sdcard logging: add voltage, remove cwa
This commit is contained in:
Verkehrsrot 2022-01-28 21:43:39 +01:00 committed by GitHub
commit e083480bf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 12 deletions

View File

@ -252,16 +252,17 @@ These cheap devices often handle SD-cards up to 32GB, not bigger ones. They can
The software included here writes data in a file named PAXCOUNT.xx, where xx can range from 00 to 99. The software starts with 00, checks to see if such a file already exists and if yes it will continue with the next number (up to 99 - in this case it will return no sd-card). So an existing file will not be overwritten. The software included here writes data in a file named PAXCOUNT.xx, where xx can range from 00 to 99. The software starts with 00, checks to see if such a file already exists and if yes it will continue with the next number (up to 99 - in this case it will return no sd-card). So an existing file will not be overwritten.
The data is written to the card and after 3 write-operations the data is flushed to the disk. So maybe the last 3 minutes of data get lost when you disconnect the PAXCOUNTER from power. The data is written to the card and after 3 write-operations the data is flushed to the disk. Thus, up to the last 3 records of data will get lost when the PAXCOUNTER looses power.
And finally: this is the data written to the disk: And finally: this is the data written to the disk:
timestamp, wifi, ble timestamp,wifi,ble[,voltage]
2022-01-28T19:36:35Z,17,48 2022-01-28T19:36:35Z,17,48
2022-01-28T19:37:35Z,21,52 2022-01-28T19:37:35Z,21,52
2022-01-28T19:38:35Z,14,49 2022-01-28T19:38:35Z,14,49
Format of the data is CSV, timestamp is ISO8601, which can easily imported into LibreOffice, Excel, Influx, etc. Format of the data is CSV, timestamp is ISO8601, which can easily imported into LibreOffice, Excel, Influx, etc.
Voltage is logged, if the device has a battery voltage sensor (to be configure in board hal file).
If you want to change this please look into src/sdcard.cpp and include/sdcard.h. If you want to change this please look into src/sdcard.cpp and include/sdcard.h.

View File

@ -55,10 +55,10 @@
#endif #endif
#define SDCARD_FILE_NAME "/paxcount.%02d" #define SDCARD_FILE_NAME "/paxcount.%02d"
#define SDCARD_FILE_HEADER "timestamp, wifi, ble" #define SDCARD_FILE_HEADER "timestamp,wifi,ble"
#if (COUNT_ENS) #if (defined BAT_MEASURE_ADC || defined HAS_PMU)
#define SDCARD_FILE_HEADER_CWA ",cwa" #define SDCARD_FILE_HEADER_VOLTAGE ",voltage"
#endif #endif
bool sdcard_init(void); bool sdcard_init(void);

View File

@ -40,7 +40,7 @@ bool sdcard_init() {
} }
void sdcardWriteData(uint16_t noWifi, uint16_t noBle, void sdcardWriteData(uint16_t noWifi, uint16_t noBle,
__attribute__((unused)) uint16_t noBleCWA) { __attribute__((unused)) uint16_t voltage) {
static int counterWrites = 0; static int counterWrites = 0;
char tempBuffer[20 + 1]; char tempBuffer[20 + 1];
time_t t = time(NULL); time_t t = time(NULL);
@ -59,8 +59,8 @@ void sdcardWriteData(uint16_t noWifi, uint16_t noBle,
fileSDCard.print(tempBuffer); fileSDCard.print(tempBuffer);
snprintf(tempBuffer, sizeof(tempBuffer), ",%d,%d", noWifi, noBle); snprintf(tempBuffer, sizeof(tempBuffer), ",%d,%d", noWifi, noBle);
fileSDCard.print(tempBuffer); fileSDCard.print(tempBuffer);
#if (COUNT_ENS) #if (defined BAT_MEASURE_ADC || defined HAS_PMU)
snprintf(tempBuffer, sizeof(tempBuffer), ",%d", noBleCWA); snprintf(tempBuffer, sizeof(tempBuffer), ",%d", voltage);
fileSDCard.print(tempBuffer); fileSDCard.print(tempBuffer);
#endif #endif
#if (HAS_SDS011) #if (HAS_SDS011)
@ -105,8 +105,8 @@ void createFile(void) {
if (fileSDCard) { if (fileSDCard) {
ESP_LOGD(TAG, "SD: file opened: <%s>", bufferFilename); ESP_LOGD(TAG, "SD: file opened: <%s>", bufferFilename);
fileSDCard.print(SDCARD_FILE_HEADER); fileSDCard.print(SDCARD_FILE_HEADER);
#if (COUNT_ENS) #if (defined BAT_MEASURE_ADC || defined HAS_PMU)
fileSDCard.print(SDCARD_FILE_HEADER_CWA); // for Corona-data (CWA) fileSDCard.print(SDCARD_FILE_HEADER_VOLTAGE); // for battery level data
#endif #endif
#if (HAS_SDS011) #if (HAS_SDS011)
fileSDCard.print(SDCARD_FILE_HEADER_SDS011); fileSDCard.print(SDCARD_FILE_HEADER_SDS011);

View File

@ -120,9 +120,9 @@ void sendData() {
#endif #endif
#if (HAS_SDCARD) #if (HAS_SDCARD)
sdcardWriteData(libpax_macs_wifi, libpax_macs_ble sdcardWriteData(libpax_macs_wifi, libpax_macs_ble
#if (COUNT_ENS) #if (defined BAT_MEASURE_ADC || defined HAS_PMU)
, ,
cwa_report() read_voltage()
#endif #endif
); );
#endif // HAS_SDCARD #endif // HAS_SDCARD