Please help spi & sd on htcc-ab02s

Hi all,

I am writting because i don’t know what it’s happening with my device(HTCC-AB02S) and a Micro-SD reader using SPI. I have tried to follow the examples that I found on internet but none of them work. I have tried using the first SPI(LORA) and the second SPI. I know my SD reader works as it works perfectly with and Arduino so it must be related to the Heltec HTCC-AB02S. Any ideas? i am just trying to establish the connection with the SD by using SD.begin(CS).

@jasonXu @Veg33 @Supporter any help, will be much appreciate.

Thanks.

Hi @MasterTribuno,

I didn’t get any reply from @jasonXu or @Supporter about the problems with the SD reader. I am starting to believe there is something wrong with the cubecell chip. I read that more people were having the same issue or similar so it makes me thing that the problem is the board. Hopefully, Someone will help us as I would like to have by early next year.

Regards,

Hi,

Sorry about the late. we have modified the code.

And it’s work fine.
%E5%9B%BE%E7%89%87

#include <SPI.h>
#include <SD.h>

File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  
  digitalWrite(GPIO2, OUTPUT);
  
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  if (!SD.begin(GPIO2)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop() {
  // nothing happens after setup
}

Hi @jasonXu ,

I have tried with your code and I don’t get anything on the serial monitor. Not even “Initializing SD card…”
It should be simple but i don’t know what I am missing. I have done a image where you can see my connections just in case I am doing it wrong.

Is that what you are expecting? Is there any errors?

@MasterTribuno Did you have any luck?

@jasonXu thanks for your help.

Regards,

hi,

Hi @jasonXu,

I managed to get the TEST.TXT but nothing inside, I have noticed too that none of the messages are being printed on the serial monitor. Is that normal? What am I missing? I am missing something? I have format the SD but still nothing.
Any ideas?

Regards,

hi,

Maybe you can use an oscilloscope to check the output level of several pins of SPI.

Or change a board.

Hello, could you help me with these two questions please.

With what lines of code can you create a folder?
With what line of code can you add content to the created document?