Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Domingo
#80271 Is there a reliable way to proxy all serial outputs, code generated and errors to a file inside the SPIFFS of the ESP?

I have an ESP8266 running that sometimes crash and restarts. I want to monitor my device state, but I can't have it connect to a serial console all day, what will be ideal is to proxy all the data that normally goes out to Serial into a file. I know there flash size limitation but one idea could be after adding a certain amount of lines to it, just start from 0 again, and stop after a crash or a restart due to a crash.
User avatar
By pipi61
#80272 Hi!
The flash rewriting count limited, few. Continuous writing quickly destroys.
Use external eeprom or fram. Use similar https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=arduino+eeprom&_sacat=0 module,
or https://www.ebay.com/sch/i.html?_odkw=fram+memory&_osacat=0&_from=R40&_trksid=m570.l1313&_nkw=fram+24c256+memory&_sacat=0
Chek eeprom/fram power specification 5/3.3V, scl-sda pull only 3.3V
User avatar
By McChubby007
#80273 Personally, I would stream each log over wi-fi to a remote 'thing' for persistent storage.

A useful tip is to redirect all low-level file I/O calls (like stdout which is defined on esp8266) to your own function and then it will intercept all printf and fprintf calls automatically. That can then stream wherever you like. It can be done on a file by file basis (when I say file, I mean a FILE struct which is just a handle to a virtual file of course).

Have a look at fopencookie() function - it is a Linux standard which is also implemeneted as standard on esp8266. I use this so that I can use regular fread/write/fprintf etc which then gets intercepted by your own functions and can be directed wherever you like I.e. I can fprintf over a wifi connection. I do have examples but they are packaged up into my TRAP debug library and so it's difficult to show you bits, but google "fopencookie", and once you have had a read you can always post a question about it here and I will answer, but you will need to understand some of it first, as I'm not in a position to explain from first principles. You may, of course, think it's too complicated/too much work for your needs and I understand.