M5Paper sd card issues
-
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)
{}
-
@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)
-
Hi, you have M5Paper?
you can try this sniplet?
regards
A -
@yellowelise Please follow my instructions about what you need to post to get help.
Also, see what statements are and are not necessary. -
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) { }