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

    Core S3 SD/TF Card Issues

    Arduino
    3
    5
    3.5k
    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.
    • D
      djh82uk
      last edited by

      Hi Guys,

      I have a core S3 that I am trying to program via the Arduino IDE as UiFlow 2 is missing a lot of the capabilites for the S3.

      I have also tried this with a standard ESp32 S3 board and get the same issue but could do with some guidance.

      My Code:

          // Include required libraries
          #include "M5CoreS3.h"
          #include "Arduino.h"
          #include "Audio.h"
          #include "SD.h"
          #include "FS.h"
          
          // microSD Card Reader connections
          #define SD_CS         15
          #define SPI_MOSI      37 
          #define SPI_MISO      35
          #define SPI_SCK       36
          
          // I2S Connections
          #define I2S_DOUT      39
          #define I2S_BCLK      40
          #define I2S_LRC       41
          
          // Create Audio object
          Audio audio;
          
          void setup() {
              M5.begin();
              // Set microSD Card CS as OUTPUT and set HIGH
              pinMode(SD_CS, OUTPUT);      
              digitalWrite(SD_CS, HIGH); 
              
              // Initialize SPI bus for microSD Card
              SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
              
      
              USBSerial.print("MOSI: ");
              USBSerial.println(MOSI);
              USBSerial.print("MISO: ");
              USBSerial.println(MISO);
              USBSerial.print("SCK: ");
              USBSerial.println(SCK);
              USBSerial.print("SS: ");
              USBSerial.println(SS);  
              SPIClass SPI1(HSPI);
              // Start microSD Card
              if(!SD.begin(SD_CS, SPI1))
              {
                USBSerial.println("Error accessing microSD card!");
                while(true); 
              }
              
              // Setup I2S 
              audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
              USBSerial.println("Pinout Set!");
              // Set Volume
              audio.setVolume(5);
              USBSerial.println("Volume Set Set!");
              // Open music file
              audio.connecttoFS(SD,"/demo.mp3");
              USBSerial.println("File Open!");
          }
          
          void loop()
          {
              audio.loop();    
          }
      

      Basically, I keep getting the message "Error accessing microSD card!" on the terminal. Pretty sure I have the pins right? And the card is formatted to FAT32.

      For some reason, I just cannot get it to read

      Any Ideas?

      Thanks

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

        Hello @djh82uk

        firstly SD_CS is GPIO 4 - see pin map here.

        Secondly it looks like the TFT (which also uses SPI) uses MISO as DC. From an ESP32 perspective MISO is an input but DC needs to be an output. So the TFT driver configures the MISO GPIO to an output. This conflicts with the SD card, which is on the same SPI bus and requires MISO to be an input. Not sure how to resolve that so that TFT and SD card can coexist.

        Thirdly the M5CoreS3 library sets the voltage for the SD card incorrectly to 1.3 V instead of 3.3 V. I posted a PR for that.

        A simple SD card example which works for me (but it disables the TFT) is here.

        Thanks
        Felix

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

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

          Hello @djh82uk

          I found a way to use the SD card w/o compromising the TFT. You can find it here.

          Thanks
          Felix

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

          L 1 Reply Last reply Reply Quote 0
          • L
            LordInchcape @felmue
            last edited by

            @felmue Hello. Does a micropython example of this exist? Thanks.

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

              Hello @LordInchcape

              not that I know of. That said, have you tried to see what Micropython code UIFlow2 produces?

              Thanks
              Felix

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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post