Upon boot, a new csv file should be created in the SD card.
The filename will have the prefix "energy-meter" followed by the current date and time when the file was created in ISO format, which will be YYYY-MM-DD_HHMMSS (example: _energy-meter__2024-05-10173028.csv)
The current time should be extracted first via an NTP time sync as soon as the ESP32 is connected to WiFi
The same filename will be used for the remaining time the device is powered on
When the device is powered off and powered on next time, a new file should be created with the new time
The first time the file is created, it should write the following header: Date/Time, Voltage, Current, Power (there should be no spaces between each word)
All subsequent writes to the file will be a single line that contains the actual data in csv format (example: 2024-05-10 17:30:28,121,5.01,606.21)
A properly formatted example csv file after a few write cycles will look like this:
Note that the time interval between each data point is increments of 5 seconds in the above example. The actual time interval of logging will be defined in a configuration file and can be updated as needed. The ESP32 should use internal RTC to ensure the data is captured at the exact time for continuity. This can be worked on later, for now, just use delay to save data to SD card
YYYY-MM-DD_HHMMSS
(example: _energy-meter__2024-05-10173028.csv)2024-05-10 17:30:28,121,5.01,606.21
)