So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Dave Wave
#74384 So I am building a weather station.

If the Wifi goes down, I want to be able to cache the data on the ESP8266 until the Wifi comes back up.

I am planning on using the ESP-07, which has 4MB eeprom.

I would like to be able to have 1MB of space if possible.

What is the best way of setting up such a structure?

All the data is ASCII text and should reside in a FIFO stack that can be appended as new data arrives, then flushed when the wifi comes back up.

Thanks,

-Dave
User avatar
By btidey
#74400 One way would be to use the SPIFFS filing system. Spool the data to file(s) and then when connection is available download the data from the file(s) and delete them.

I think I'd be tempted to locally buffer, say 8KB, in RAM and then write that to individual files when the buffer got full.
User avatar
By Dave Wave
#74410 Are there any good tutorials for learning to use SPIFFS?

How much free RAM is available? I thought these chips had just about nothing free in normal operation.

I was planning to use CSV to store the data in a FIFO stack or file. Any pointers on what to read/study when trying to come up with a system? I do not suppose there is a library that might be applicable?

Thanks,

-Dave
User avatar
By btidey
#74416 SPIFFS is documented at
http://esp8266.github.io/Arduino/versio ... ystem.html

It is not RAM. It is a filing system which uses spare Flash memory on the device. So with a 4MB Flash you can use 1MB for program and 3MB for the filing system. That is set up in the Arduino Tools set up.

Once formatted then it behaves like a simple filing system and you create, read, write and delete files just like you would normally. Files that get written will stay there even over restarts until they are explicitly deleted.

So you could create a file and write your data to it with normal stream functions. As I said it could be beneficial to write to a RAM buffer as an intermediate store and only create a file when that is full. That would reduce the amount of reading and writing to Flash.

When you have a connection then you can open any files in order, read them and send any data back before deleting them. If using the RAM buffer you would need to send its contents too.