[Grow:Dashboard] Sensor Data logging to LittleFS #35

Closed
opened 2025-04-01 18:26:48 +02:00 by DeltaLima · 3 comments
Owner

Some sensor values would be interesting to track and visualize as timegraph on the dashboard.

Writing the sensor readings to LittleFS should be configurable in the sensor calibration (because there is every reading present) or as Option within the dashboard settings.

Data on LittleFS could be stored like

| 
| data/
| -- [sensorID]/
|     -- [readingId]/
|         -- [YYYYMMDD].csv

the csv would contain two columns, timestamp and value (float)

1743523193,4.20
1743526793,4.10
1743530393,4.42

Appending the file every hour would be enought imho. This could be a timer beginning from startup time , or something which executes exactly at full hour. I guess the first option is the easiest to implement and should be taken for the beginning.

Keeping 7 days of data would be enough i guess. This could be configurable.

Filename schema is YYYYMMDD.

To cleanup old files, we can just check if(20250329 < 20250401). To calculate this date string of the oldest file, we can do something like datestring_oldest = year(now() - (60*60*24*7)) + month(now() - (60*60*24*7)) + day(now() - (60*60*24*7))

Some sensor values would be interesting to track and visualize as timegraph on the dashboard. Writing the sensor readings to LittleFS should be configurable in the sensor calibration (because there is every reading present) or as Option within the dashboard settings. Data on LittleFS could be stored like ``` | | data/ | -- [sensorID]/ | -- [readingId]/ | -- [YYYYMMDD].csv ``` the csv would contain two columns, timestamp and value (float) ```csv 1743523193,4.20 1743526793,4.10 1743530393,4.42 ``` Appending the file every hour would be enought imho. This could be a timer beginning from startup time , or something which executes exactly at full hour. I guess the first option is the easiest to implement and should be taken for the beginning. Keeping 7 days of data would be enough i guess. This could be configurable. Filename schema is `YYYYMMDD`. To cleanup old files, we can just check `if(20250329 < 20250401)`. To calculate this date string of the oldest file, we can do something like `datestring_oldest = year(now() - (60*60*24*7)) + month(now() - (60*60*24*7)) + day(now() - (60*60*24*7))`
Author
Owner

for splitting the csv string when reading the files, this comes handy
https://cplusplus.com/reference/cstring/strtok/

for splitting the csv string when reading the files, this comes handy https://cplusplus.com/reference/cstring/strtok/
Author
Owner

data logging works fine so far on esp8266. on ESP32 there is a bug, see #40

data logging works fine so far on esp8266. on ESP32 there is a bug, see #40
Author
Owner

Data Loggin done, bug solved :)

Data Loggin done, bug solved :)
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
DeltaLima/CanGrow#35
No description provided.