Iotalog.log damaged, repeatedly deleted

Hi, last night I noticed that I lost the entire power consumption history in the grapher. Logs show that there is a log file that is damaged and is getting repeatedly deleted.

Also, every few days Home assistant receives spurious power readings in the MW or GW range - but this may be a separate issue as it doesn’t always correspond to the iotawatt reboots. Last night when Iotawatt rebooted and nuked the history, there was a MW spike in Home assistant.

Is there anything I can do to prevent the power history from being deleted again?

** Restart **

SD initialized.
10/02/22 07:20:46z Real Time Clock is running. Unix time 1664695246 
10/02/22 07:20:46z Reset reason: Software Watchdog
10/02/22 07:20:46z Trace:  34:0, 34:5, 34:5, 34:5, 34:6[1], 34:10[5], 34:0, 34:5, 34:5, 34:5, 34:6[1], 34:10[4], 34:0, 34:5, 34:5, 34:5, 34:6[1], 34:10[3], 34:0, 34:5, 34:5, 34:5, 34:6[1], 34:10[2], 34:0, 34:5, 34:5, 34:5, 34:6[1], 34:10, 25:18, 25:19
10/02/22 07:20:46z ESP8266 ID: 570217, RTC M41T81 (68)
10/02/22 07:20:46z IoTaWatt 5.0, Firmware version 02_07_05
10/02/22 07:20:46z SPIFFS mounted.
10/01/22 21:20:46 Local time zone: -10:00
10/01/22 21:20:46 device name: IotaWatt
10/01/22 21:20:46 HTTP server started
10/01/22 21:20:46 timeSync: service started.
10/01/22 21:20:46 statService: started.
10/01/22 21:20:46 dataLog: service started.
10/01/22 21:20:46 IotaLog: file damaged /iotawatt/iotalog.log

10/01/22 21:20:46 IotaLog: Creating diagnostic file.
10/01/22 21:21:08 IotaLog: Deleting /iotawatt/iotalog.log and restarting.


** Restart **

SD initialized.
10/02/22 07:21:09z Real Time Clock is running. Unix time 1664695269 
10/02/22 07:21:09z Reset reason: Software/System restart
10/02/22 07:21:09z Trace:  1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:1[14], 1:2, 9:0, 9:0, 8:4, 8:6, 8:8, 8:9, 1:2, 1:3, 1:3, 1:6[1], 1:6[3], 1:5[19], 1:6[4]
10/02/22 07:21:09z ESP8266 ID: 570217, RTC M41T81 (68)
10/02/22 07:21:09z IoTaWatt 5.0, Firmware version 02_07_05
10/02/22 07:21:09z SPIFFS mounted.
10/01/22 21:21:09 Local time zone: -10:00
10/01/22 21:21:09 device name: IotaWatt
10/01/22 21:21:09 HTTP server started
10/01/22 21:21:09 timeSync: service started.
10/01/22 21:21:09 statService: started.
10/01/22 21:21:09 dataLog: service started.
10/01/22 21:21:09 dataLog: New current log created.
10/01/22 21:21:13 WiFi connected. SSID=HaleKao, IP=10.1.1.141, channel=11, RSSI -57db
10/01/22 21:21:13 MDNS responder started for hostname IotaWatt
10/01/22 21:21:13 LLMNR responder started for hostname IotaWatt
10/01/22 21:21:13 Updater: service started. Auto-update class is MINOR
10/01/22 21:21:14 Updater: Auto-update is current for class MINOR.
10/01/22 21:21:14 grid_int: Started
10/01/22 21:21:14 grid_int: Last log entry 10/01/22 21:20:40
10/01/22 21:21:14 solar_int: Started
10/01/22 21:21:14 solar_int: Last log entry 10/01/22 21:20:40
10/01/22 21:22:14 historyLog: service started.
10/01/22 21:22:14 historyLog: Log file open failed: 2, service halted.

** Restart **

SD initialized.
10/05/22 04:47:51z Real Time Clock is running. Unix time 1664945271 
10/05/22 04:47:51z Reset reason: Software Watchdog
10/05/22 04:47:51z Trace:  34:0, 34:5, 34:5, 34:5, 34:6[1], 34:10[5], 34:0, 34:5, 34:5, 34:5, 34:6[1], 34:10[4], 34:0, 34:5, 34:5, 34:5, 34:6[1], 34:10[3], 34:0, 34:5, 34:5, 34:5, 34:6[1], 34:10[2], 34:0, 34:5, 34:5, 34:5, 34:6[1], 34:10, 25:18, 25:19
10/05/22 04:47:51z ESP8266 ID: 570217, RTC M41T81 (68)
10/05/22 04:47:51z IoTaWatt 5.0, Firmware version 02_07_05
10/05/22 04:47:51z SPIFFS mounted.
10/04/22 18:47:51 Local time zone: -10:00
10/04/22 18:47:51 device name: IotaWatt
10/04/22 18:47:51 HTTP server started
10/04/22 18:47:51 timeSync: service started.
10/04/22 18:47:51 statService: started.
10/04/22 18:47:51 dataLog: service started.
10/04/22 18:47:51 IotaLog: file damaged /iotawatt/iotalog.log

10/04/22 18:47:51 IotaLog: Creating diagnostic file.
10/04/22 18:48:15 IotaLog: Deleting /iotawatt/iotalog.log and restarting.


** Restart **

SD initialized.
10/05/22 04:48:16z Real Time Clock is running. Unix time 1664945296 
10/05/22 04:48:16z Reset reason: Software/System restart
10/05/22 04:48:16z Trace:  1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:3, 1:1[14], 1:2, 9:0, 9:0, 8:4, 8:6, 8:8, 8:9, 1:2, 1:3, 1:3, 1:6[1], 1:6[3], 1:5[19], 1:6[4]
10/05/22 04:48:16z ESP8266 ID: 570217, RTC M41T81 (68)
10/05/22 04:48:16z IoTaWatt 5.0, Firmware version 02_07_05
10/05/22 04:48:16z SPIFFS mounted.
10/04/22 18:48:16 Local time zone: -10:00
10/04/22 18:48:16 device name: IotaWatt
10/04/22 18:48:16 HTTP server started
10/04/22 18:48:16 timeSync: service started.
10/04/22 18:48:16 statService: started.
10/04/22 18:48:16 dataLog: service started.
10/04/22 18:48:16 dataLog: New current log created.
10/04/22 18:48:20 WiFi connected. SSID=HaleKao, IP=10.1.1.141, channel=10, RSSI -53db
10/04/22 18:48:20 MDNS responder started for hostname IotaWatt
10/04/22 18:48:20 LLMNR responder started for hostname IotaWatt
10/04/22 18:48:20 Updater: service started. Auto-update class is MINOR
10/04/22 18:48:21 Updater: Auto-update is current for class MINOR.
10/04/22 18:48:21 grid_int: Started
10/04/22 18:48:21 grid_int: Last log entry 10/04/22 18:47:45
10/04/22 18:48:21 solar_int: Started
10/04/22 18:48:21 solar_int: Last log entry 10/04/22 18:47:45
10/04/22 18:49:20 historyLog: service started.
10/04/22 18:49:20 historyLog: Log file open failed: 2, service halted.

Here is logdiag.txt

10/04/22 18:47:51
filesize 12807168, entries 50018
1664695270,0,1664945200,49986
-478344139,52035,-478344139,52035
1664945210,49988,1664945210,49988
1664945215,8446789,1664945215,8446789
1128074308,49990,1128074308,49990
1664945225,49991,1664945225,49991
1664945230,-2147368120,1664945230,-2147368120
1933315667,4244297,1933315667,4244297
1128074328,49994,1128074328,49994
1669139549,1073791819,1669139549,1073791819
1664945250,49996,1664945265,49999
0,-2147352576,0,-2147352576
1048576,0,1048576,0
0,0,0,0
256,0,256,0
0,0,0,0
0,0,0,0
128,112,128,112
0,0,0,0
0,0,0,0
0,8,0,8
0,16777472,0,16777472
0,33554432,0,33554432
256,32,256,32
0,0,0,0
0,0,0,0
0,10485760,0,10485760
134217984,536870912,134217984,536870912
138412032,2048,138412032,2048
67108864,0,67108864,0
536903680,0,536903680,0
0,0,0,0
0,0,0,0
0,0,0,0
0,0,0,0
0,0,0,0
0,0,0,0
0,0,0,0
0,0,0,0
End of file

Probably should replace the SDcard. There’s info about that in the Resources category.

Following up on this, I did replace the SD card following the instructions provided. I used a high-endurance Sandisk SD card, though that branding may just be a placebo :grinning:

All has been running flawlessly the past few weeks since the change. I previously would see spurious data points (in the MW range) every few days – that problem has disappeared too.

FWIW the iotawatt was less than a year old. Nevertheless, the new SD card was cheap, the fix was easy, and hopefully a higher endurance card will be more reliable.

1 Like

The “industrial” cards are very expensive. SD failure has been relatively rare. About a year ago, improvements were made to drastically reduce the number of writes to the card. Since then, very few card failures have been reported and most of those were units that had been in service for several years and possibly the damage was a result of other issues that have been fixed.

The nature of flash memory is that it “wears” out with repetitive writing. Modern cards have firmware to reallocate high usage blocks and sectors, but the algorithms are proprietary and there is no practical way of knowing what the card has or how effective it is.

My home unit has had the same card for at least three years. I changed it after several years in service, copying the full contents to a new card (couple of minutes in a PC). I currently have almost six years of data on the SD.

image

While I expect most cards to last ten years or more, I would recommend replacing a card more than several years old if preserving history is a priority. It’s not necessary to go overboard. A standard 8GB SDHC class 10 card is fine and costs under 10 bucks. 8GB can easily hold up to 10 years of history with plenty of extra space. Be sure to read this to avoid damaging the card when removing.