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

    M5Paper sd card issues

    Scheduled Pinned Locked Moved PRODUCTS
    5 Posts 3 Posters 10.0k Views 3 Watching
    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.
    • yelloweliseY Offline
      yellowelise
      last edited by

      I Have problem with Sd card in my first batch M5Paper, I try this code but don't works, anyone can try in it's m5paper?

      #include <M5EPD.h>
      File myFile;
      void setup(void)
      {
      M5.begin();
      Serial.begin(115200);
      SPI.begin(14, 13, 12, 4);
      bool ret = SD.begin(4, SPI, 20000000);
      if(ret == false)
      Serial.print("SD ERROR...\n");
      else
      {
      Serial.print("SD OK...\n");
      if (SD.exists("screen.txt"))
      Serial.print("screen.txt exists...\n");
      else
      Serial.print("screen.txt NOT exists...\n");
      Serial.print("Try to create screen.txt...\n");
      myFile = SD.open("screen.txt", FILE_WRITE);
      myFile.println("Some text...");
      myFile.close();
      if (SD.exists("screen.txt"))
      Serial.print("now screen.txt exists...\n");
      else
      Serial.print("not jet screen.txt exists...\n");
      }

      }

      void loop(void)
      {

      }

      K sambartleS 2 Replies Last reply Reply Quote 0
      • K Offline
        kevindtimm @yellowelise
        last edited by

        @yellowelise you can skip the SPI.begin(), it's not necessary.
        SD.begin(4); is all that's necessary for that call.
        There are issues with SD cards bigger than 16GB in some cases.

        BTW, when you report these issues it would be much better if you would report what errors you get as well as how far the program got (show the output)

        1 Reply Last reply Reply Quote 0
        • yelloweliseY Offline
          yellowelise
          last edited by

          Hi, you have M5Paper?
          you can try this sniplet?
          regards
          A

          K 1 Reply Last reply Reply Quote 0
          • K Offline
            kevindtimm @yellowelise
            last edited by

            @yellowelise Please follow my instructions about what you need to post to get help.
            Also, see what statements are and are not necessary.

            1 Reply Last reply Reply Quote 0
            • sambartleS Offline
              sambartle @yellowelise
              last edited by sambartle

              @yellowelise

              You have to do / when referencing the root in Arduino SD libraries..

              I've modified your example to output to the screen instead of serial and fixed it for you.. (I left the syntactically redundant exists, try create anyways, exists code in as that's what the original example did, it probably needs another if)

              #include <M5EPD.h>
              
              M5EPD_Canvas canvas(&M5.EPD);
              
              File myFile;
              void setup(void)
              {
                M5.begin();
                M5.EPD.SetRotation(90);
                M5.EPD.Clear(true);
                M5.RTC.begin();
                canvas.createCanvas(540, 400);
                canvas.setTextSize(3);
              
              
                bool ret = SD.begin(4, SPI, 20000000);
                if(ret == false)
                  canvas.drawString("SD ERROR...", 45, 100);
                else  
                {
                  canvas.drawString("SD OK...", 45, 100);
                  if (SD.exists("/screen.txt"))
                    canvas.drawString("Screen.txt Exists...", 45, 150);
                  else
                    canvas.drawString("Screen.txt Not Exists...", 45, 150);
                  canvas.drawString("Try create Screen.txt", 45, 200);
                  myFile = SD.open("/screen.txt", FILE_WRITE);
                  myFile.println("Some text...");
                  myFile.close();
                  if (SD.exists("/screen.txt"))
                    canvas.drawString("Screen.txt Exists...", 45, 250);
                  else
                    canvas.drawString("Screen.txt Still Not Exists...", 45, 250);
                }
              
                canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
              }
              
              void loop(void)
              {
              
              }
              
              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