Check SD Card Status

  • I know how to read and write the SD Card but I am unsure how to check the status. I have tried using Try and Except but still have not go where I wanted. The goal is to tell if an SD card is inserted and formatted if not prompt the user to insert a proper card. Since I am presently working in Blockly and inserting Python code using the Execute block a solution that met this requirement would be great. Thanks

  • Ok, I have figured out how to detect when the card is ejected by writing a file within a try - except but once the card is out I have not figured out how to get it re-mounted in code. I can get it re-mounted by resetting the CORE2. The scenario would be you eject the card and the CORE2 detects it and notifies the user to insert a new card. Once the card is inserted the CORE2 would automatically mount it and make it available for use. I am sure there is a simple command that I am missing.
    Thanks for any help.

    with open('/sd/IsCard.txt', 'w+') as fs:
    fs.write('Test Write')
    with open('/sd/IsCard.txt', 'r') as fs:
    label0.set_text('Card has been read')
    NoCard = 0
    NoCard = 1
    label0.set_text('Card Not Installed1')

  • After consulting with M5Stack tech support they indicated the only way to re-mount a card after it has been ejected and re-inserted is to reboot the device.

  • Hello @SE

    thank you for sharing. The answer is not really surprising though - the required SDCard detect pin is not connected at all according to the schematics of M5Stack (Fire, Gray, etc.) and M5Core2.

    Interestingly it is connected in M5Paper, so SDCard detection should be possible there. But before you get your hopes up - SDCard support is not available yet in the UIFlow alpha version for M5Paper.