-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Buffer on SPFFIS or SD Card #41
Comments
Hi @gomez100 , this is a good idea - however, I' also not sure if this should be in the scope of this library. With what kind of data are you dealing with? Most (arduino) applications I've seen so far which use this library "just" collect sensor data or simple metrics metrics for whose it is not critical if there are some data points missing. Many of them even don't have any storage. Therefore I would suggest to either save the points in the buffer manually if writing fails and you want the device to go to deep sleep or not to use buffering of this library but to implement you own buffering strategy. Still, feel free to create a PR. :-) |
Hi Tobias, |
@gomez100, use InfluxDBClient::writeRecord() to write line protocol directly. Be sure to sync time and use Point::setTime to set correct time to your saved data. However, line protocol is not good for saving space. I would suggest storing your data in a raw form (a binary) with timestamp, if possible, a then create data Point at the time of writing. When using SPFFIS, consider the fact, that this is flash memory with limited number of writes. |
@vlastahajek I totally agree with you about the SPFFIS, and SD card seems to be the best solution even when much power consumption ( for writes cycle and available space). Your suggestion is:
|
After a long search and the same idea, I ended up here. The inline protocol can also be created using a simple string addition. The generated file can be read out here without any problems: SPIFFS.begin();
File f;
f = SPIFFS.open(POINTS_FILE, "r");
while (f.available()) {
char buff[256] = { 0 };
f.readBytes(buff, 256);
Serial.print(&buff[0]);
client.writeRecord(&buff[0]);
} Only the client.writeRecord-command doesn't work because it doesn't pass the file as a stream - I get error messages, each with 256-byte pieces - and it's slow because the function used in the ESP8266http client passes the whole file byte by byte (searching for "\r")². influxDB supports sending files³:
and it worked here and --data-binary indicates that these are not line by line excerpts from text files. ² ESP8266HTTPClient takes very long time to send 1MB file(SPIFFS) I would also be very grateful for ideas. In the moment, I'm refuelling myself through the ESP8266httpClient.cpp, hoping to solve the whole thing without the Influx library - since I don't need a general solution, but only a specialized one. |
@marmat123 have you worked out the bast way to save and then send points from SPIFFS? |
I'm gonna say +1 for this feature to be able to choose where the program stores the buffer, if that's possible. In my case I am making a portable setup which will remain at home a lot of the time and it will be logging data from various water sensors (flow, psi, TC, etc). However, when I leave home with the setup I want the ESP to continue saving the data points to the SD card, then once I get back home, have it automatically continue uploading the data from the SD card to Influx. I'm relatively new to programming ESP's/Arduino's so making custom code that hasn't been done before is not easy for me, although it seems like I will have to try in this case because this feature request is nearing 2 years in age. |
Hi Tobias,
it should be good having the option to store buffer in SPFFIS or SD Card for data sampled each minute or more, so it's possible to put ESP in deepsleep without losing buffered data.
Regards,
Andrea
The text was updated successfully, but these errors were encountered: