-
Notifications
You must be signed in to change notification settings - Fork 0
Description
I'm using an ESP32 feather from Adafruit for development. It uses an ESP WROOM 32 module with 4mb flash and 520kb ram. I'm using the Arduino framework, so information about how it slices the memory and flash is available somewhere. Currently the data is stored in a vector of SensorData structs. A SensorData struct:
Firmware/include/plant/sensors/sensor.h
Lines 21 to 24 in 881d03b
| struct SensorData { | |
| float value; | |
| char timestamp[TIMESTAMP_LENGTH]; | |
| }; |
The data is then written to a file in json format. I will post an example of this later. The sensors are read every 10 minutes, and each data point is kept for 12 hours. How long the vector can be is calculated based on math in the config file:
Lines 33 to 40 in 881d03b
| // Data Collection Settings | |
| #define CHECK_SENSOR_PERIOD_MINUTES 10 | |
| #define DATA_MAX_AGE_HOURS 12 | |
| // Data Collection Math | |
| #define CHECK_SENSOR_PERIOD (CHECK_SENSOR_PERIOD_MINUTES * TASK_MINUTE) | |
| #define DATA_MAX_AGE (DATA_MAX_AGE_HOURS * TASK_HOUR) | |
| #define DATA_MAX_SIZE (DATA_MAX_AGE / CHECK_SENSOR_PERIOD) |
I need to know how much memory and flash this data takes up per data point per sensor, if using a vector vs an array or a custom datatype would make a difference, and how much flash is dedicated to SPIFFS/memory is dedicated to code. From this information, sensible defaults can be created. Remember to factor in how big the rest of the SPIFFS files are (perhaps some treeshaking can be done to minimize unused code) for flash, and for memory factor in how much is taken up by normal use as well as the initial overhead caused by loading the data after a reboot into a dynamic Json document.