SD card health monitoring

For over a year now we’ve been including sandisk industrial grade SD cards in all emonPi, emonBase and emonSD units. We’ve not had a single reported issue.

As mentioned on the bottom of this thread, thanks to @wjcroft it’s possible to monitor the health of these cards:

This post is to document how to do this:

Connect via SSH then download sdmon:

curl -L https://github.com/Ognian/sdmon/releases/download/latest/sdmon-armv7.tar.gz | tar zxf - 

then run sdmon:

sudo ./sdmon /dev/mmcblk0

this should give you an output like this

"version": "v0.4.1-3 (63a79fd) armv7",
"date": "2022-08-11T02:05:07.000Z",
"device":"/dev/mmcblk0",
"addTime": "false",
"signature":"0x44 0x53",
"SanDisk":"true",
"manufactureYYMMDD": "210712",
"healthStatusPercentUsed": 1,
"featureRevision": "0x1f",
"generationIdentifier": 5,
"productString": "SanDisk                         ",
"success":true
}

This particular card which has been in heavy use for over a year is at 99% health.

In future releases of emonSD we could look at making this metric display on the Emoncms admin page.

sdmon can only read health data from certain industrial SD cards:

Here’s the sdmon repo:

Thanks @glyn.hudson

Out of interest, this is a raspberry Pi that’s been running for over 5 years continuously (not my emonPi unfortunately). Certainly looking like I need to prepare a replacement:

pi@raspberrypi:~ $ sudo ./sdmon /dev/mmcblk0
{
"version": "v0.4.1-3 (63a79fd) armv7",
"date": "2022-08-14T21:35:03.000Z",
"device":"/dev/mmcblk0",
"addTime": "false",
"read_via_cmd56_arg_1":"read successful but signature 0xff 0xff",
"idata.response[]":"0x900 0x00 0x00 0x00",
"flashId": ["0x45","0x3a","0x98","0xb3","0x76","0x72","0x0d","0x0e","0x00"],
"icVersion": ["0x1f","0xc3"],
"fwVersion": [38,131],
"ceNumber": "0x01",
"spareBlockCount": 41,
"initialBadBlockCount": 9,
"goodBlockRatePercent": 99.40,
"totalEraseCount": 425285,
"enduranceRemainLifePercent": 37.20,
"avgEraseCount": 628,
"minEraseCount": 563,
"maxEraseCount": 684,
"powerUpCount": 127,
"abnormalPowerOffCount": 47,
"totalRefreshCount": 0,
"productMarker": ["0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00"],
"laterBadBlockCount": 0,
"success":true
}

This really needs a wrapper script to post the output to MQTT and an systemd timer file to trigger it once in x (or CRON but I’m adverse to CRON). Pull in the MQTT server details from an ini rather than edit the script.

@glyn.hudson would be a great addition to the emonscripts install (optional).

I don’t have a card this will read unfortunately.

I also think it would be worth adding to the Upgrade & Update part of the guide a recommended list of SD Cards.

Interesting, thanks for sharing. Do you know what SD card this is from? What version of emonSD is it running? The output looks different from our current Sandisk SDSQQNR-032G-GN6IA

I don’t actually know what card is in that Pi - I’ll check next time I get to it.

Like I say, it’s not from my emonPi, it’s an ADSB receiver in my loft - been running for 5+ years. A few power outages here and there, and pretty nasty temps in summer. I just found it interesting for something that’s been running for such a long time to see the real-world stats on it

Here’s the results from a brand new Kingston 32GB “High Endurance” card:

pi@emonpi:~ $ sudo ./sdmon /dev/mmcblk0
{
"version": "v0.4.1-3 (63a79fd) armv7",
"date": "2022-09-03T16:01:27.000Z",
"device":"/dev/mmcblk0",
"addTime": "false",
"read_via_cmd56_arg_1":"read successful but signature 0xff 0xff",
"idata.response[]":"0x900 0x00 0x00 0x00",
"flashId": ["0x98","0x3a","0x98","0xb3","0x76","0x72","0x08","0x0e","0x00"],
"icVersion": ["0x20","0x25"],
"fwVersion": [29,63],
"ceNumber": "0x02",
"spareBlockCount": 9,
"initialBadBlockCount": 10,
"goodBlockRatePercent": 99.67,
"totalEraseCount": 694,
"enduranceRemainLifePercent": 99.97,
"avgEraseCount": 1,
"minEraseCount": 1,
"maxEraseCount": 1,
"powerUpCount": 11,
"abnormalPowerOffCount": 0,
"totalRefreshCount": 0,
"productMarker": ["0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00"],
"laterBadBlockCount": 0,
"success":true
}

I’ve swapped to a new card following all of the Dire Warnings about card life. To be fair, the old one was that well known brand “LD”.