Save readings to SPIFFS when WiFi is offline

Howdy Blynkers!

I am looking for some guidance. Where I live we have power failures at least once a week and they can last up to 2 hours.

I have a D1 MINI monitoring the temperature in my fridge with a DHT22 sensor.
The problem is that if the power fails, the Wifi also goes off and my D1 cannot connect to Blynk to show me the actual values of the fridge even if the device is on. It’s powered by a battery and I can see the LED blink when sending data, but it goes nowhere.

Is there a way to save the data to SPIFFS (which I have no idea how to start) and then upload to Blynk, when connected again, in intervals of 5 readings per second? Not sure if SPIFFS is actually the answer I’m looking for.

This data should be then stored on the Superchart at the correct time intervals of the readings, not when uploaded, like filling the missing gaps in the chart.

Any advice will be appreciated.


No, you can’t upload retrospective data to SsuperChart. All data is received by the server, held in memory and averaged over the course of one minute, then written to the database with the current time stamp.

Maybe the solution is a local Blynk server and UPS on your router and Blynk server.


Thanks @PeteKnight, so this could maybe added as an idea for Blynk?

The UPS on the router will most defiantly work and my kids would love to youtube or Netflix or whatever, when the power is down, I will consider this.

I do not know how the local Blynk server works yet, will look into it. Just a question, will it upload all data to my Blynk account when connected to Wifi again and super chart will sync?

If the online server averages data sent to it, could SPIFFS still send a load of data and display the average of it first on the chart before the next sensor read?
Or in a table maybe, with reading timestamps?
Could that saved data be displayed on the terminal widget?
Not sure about this one… if SPIFFS can upload to mySql database and if I can get it at the right timestamps, many iff’s here, would the webhook widget be able to help?

My current workaround, when I am home is using my mobile hotspot, not always ideal as it chows my phones battery and I’m not always home when it happens. I have a 5G router and sometimes (not blaming the kids :wink:) we run out of data, a “saving readings” solution would also work then.

Any additional advice?

Just to be clear, a Blynk local server replaces the cloud server that you’re running at the moment. Data would be stored locally and you’d be able to send data to it whether or not you’re connected to the internet.
Local server isn’t required to resolve your initial enquiry, provided the internet connection stays online and your local ‘switchboard’ isn’t affected by the power outage.
Local server makes the whole system bulletproof, provided you’re able to keep it and your router (which is needed for internal network routing, as opposed to providing external connection to the internet).

I don’t really understand your other questions. Maybe you should read the last part of the SuperChart documentation on Granularity, to understand how the averaging works:

There are no tools available to upload data other than Blynk.VirtualWrite or the equivalent API call (which does exactly the same thing), so try experimenting with your averaged data if you wish.


Thanks for the info @PeteKnight!