🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Check SD Card Status

    Scheduled Pinned Locked Moved UIFlow
    4 Posts 2 Posters 7.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      SE
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • S Offline
        SE
        last edited by

        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.

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

        1 Reply Last reply Reply Quote 0
        • S Offline
          SE
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • felmueF Offline
            felmue
            last edited by

            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.

            Thanks
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post