Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 12 of 12

Thread: Teensy 4 no SD-Card-found

  1. #1
    Junior Member
    Join Date
    Jan 2022

    Teensy 4 no SD-Card-found

    Hello everyone,

    i'm using this breakout-board: as preassembled version.
    Since now i got something working with I2C and Wifi and a really basic type of http-server that will return some json, now i wanted to save some Data to an SD-Card, but it wont work :(

    Tested example:
    #include <SD.h>
    #include <SPI.h>
    Sd2Card card;
    //SPI.setMOSI(7);  // Audio shield has MOSI on pin 7
    //SPI.setSCK(14);  // Audio shield has SCK on pin 14  
    void setup()
    	master.begin(400 * 1000U);
    	pinMode(led, OUTPUT);
    	// configured = configure_sensor();
        if (!card.init(SPI_HALF_SPEED, BUILTIN_SDCARD)) {
        Serial.println("initialization failed. Things to check:");
        Serial.println("* is a card inserted?");
        Serial.println("* is your wiring correct?");
        Serial.println("* did you change the chipSelect pin to match your shield or module?");
      } else {
       Serial.println("Wiring is correct and a card is present.");
    of course outputs the help-text

    i'm developing with VSCode and PlatformIO, but also with Arduino 1.8.16 its the same ...
    if i print BUILTIN_SDCARD i get "254" - is that correct?

    Based on shouln't i set setMOSI to 35?

    Currently i don't know where to start searching for the cause because i'm fairly new to this :(

    the card is a sandisc 32GB, the smallest i could found in mediamarkt ^^
    card is formated FAT32 and no problems with SD-Card-Reader in my PC

    thanks in advance for any help

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Recommend using Arduino 1.8.19 and Teensyduino 1.56, at least for testing. With PlatformIO, copies of old libraries are a common problem. So are variation in settings with INI files. Test with the latest Arduino+Teensyduino where we can help knowing exactly what code you're running, and Arduino gives a "known quantity", rather than a system which tends to vary quite a lot. Once the hardware is confirmed working with Arduino, then fiddle with PlatformIO.

    Click Arduino's File > Preferences and turn on verbose output during compilation. This causes Arduino to print lots of info while compiling. Near the end it will show you the exact paths of every library it used. Check these carefully. Make sure it's using the ones from {Arduino}/hardware/teensy/avr/libraries. A very common problem we is copies of libraries in {Documents}/Arduino/libraries which override the ones Teensyduino installs. It's easy to waste a lot of time only to finally realize the wrong copy of a library was being used, so check this first.

    In Arduino, I recommend using either File > Examples > SD > CardInfo, or File > Examples > SdFat > SdInfo.

    If it still can't detect your card, using the latest software and correct libs, then it's time to start looking at the FFC cable between your Teensy 4.0 and that Mega carrier board. I hope you can understand we'll need to see photos to help with that.

  3. #3
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    As Paul mentioned, if it were me, would try with the most recent Arduino and Teensyduinio and see if the basics work.

    It looks like an interesting Tindie board.

    When you ordered it assembled, was it also purchased with the T4. If so was the connectors soldered on and flex cable connected between the teensy and the board?

    Note: when I have done my own soldering of these connectors for myself I found that I often had problems doing so. I also found that sometimes the cables were not fully inserted and/or in straight and would have one or two signals not ring through.

    So if you run a standard basic SD example sketch modified for builtin and it does not work. If it were me, I would then probably use meter to ring through and see if I connections or more likely probably run some sketch to see if I detect that io pin.

    There are several sketches up on forum doing this, like the HiLow test mentioned several times. I know a version of it is up at:

    With it, you can use something like a jumper wire, where one end goes to either 3.3v or gnd, and if you touch a pin, it should show which pin connected to. Note; the above sketch you alternate between testing to 3.3v or gnd by hitting enter key in debug monitor...

    Note: 2 of the pins are 3.3v and gnd, so you may not want to touch those pins. To give you an idea of which ones are which here is an image of a breakout board I did at one point to plug into MicroSD connector and be able to try out the signals for other things....
    Click image for larger version. 

Name:	screenshot.jpg 
Views:	12 
Size:	64.0 KB 
ID:	27198

    I mainly show this image to give an idea of which ones are signal and which ones are power... Pin numbers may not be correct on some boards like T4.1 but...

  4. #4
    Junior Member
    Join Date
    Jan 2022
    thanks for your responses!

    - i've updated arduino and teensyduino
    - I've ringed all contacts from teensy-board to expansion-board (all about 0,3 Ohm) (i will mark them in the picture which ones i used)
    - SD-library used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD

    i've now checked the example "Cardinfo" (identical with the snipped in first post) and get the same error in console ("initialization failed. Things to check:...")

    Memory Usage on Teensy 4.0:
      FLASH: code:45972, data:7080, headers:8384   free for files:1970180
       RAM1: variables:9024, code:44264, padding:21272   free for local variables:449728
       RAM2: variables:12384  free for malloc/new:511904
    Mehrere Bibliotheken wurden für "SD.h" gefunden
     Benutzt: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
     Nicht benutzt: C:\Program Files (x86)\Arduino\libraries\SD
    Bibliothek SD in Version 2.0.0 im Ordner: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD  wird verwendet
    Bibliothek SdFat in Version 2.1.0 im Ordner: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat  wird verwendet
    Bibliothek SPI in Version 1.0 im Ordner: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI  wird verwendet
    and of course you wanted some picures:
    Click image for larger version. 

Name:	Screenshot 2022-01-13 160448.png 
Views:	19 
Size:	541.2 KB 
ID:	27200
    Click image for larger version. 

Name:	Screenshot 2022-01-13 160647.jpg 
Views:	19 
Size:	122.1 KB 
ID:	27201
    Click image for larger version. 

Name:	Screenshot 2022-01-13 160711.jpg 
Views:	19 
Size:	86.8 KB 
ID:	27202
    Click image for larger version. 

Name:	Screenshot 2022-01-13 160726.jpg 
Views:	22 
Size:	183.5 KB 
ID:	27203

    any other ideas?
    i have also some separate sd-card holders that i could connect (though i would have to look for how to), ideally the built in wourd work somehow

  5. #5
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    If it were me, and the pins rang through (And I would check at the SD connector)

    I would also try a different test then card info... I have never used it
    and wonder about the line: if (!card.init(SPI_HALF_SPEED, BUILTIN_SDCARD)) {...

    Like try the test ReadWrite.ino (modified for built in) if that works, then
    (But someone should update the other sketch)

    If not... Not sure

  6. #6
    Quote Originally Posted by KurtE View Post
    It looks like an interesting Tindie board.
    Just wanted to comment that I've used several of BurgessWorld's breakout boards with very good results. Great quality, very fast response. They also do custom work.

  7. #7
    Junior Member
    Join Date
    Jan 2022
    Hi, I build and sell these boards.

    you can check out the example sketches in my GitHub repo here:

    There is a script to test the USB port and the SD card port. Just plug in a mouse or (or wireless mouse dongle) and insert an SD card. The script initializes the SD card and updates a file when mouse movement is detected.

    This is the script that is used to test boards that are shipped fully-assembled.

    If you can get it to work, send me a private message or reach out to me via Tindie and I will send you a return label so I can look at it.

    Chris Burgess

  8. #8
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Cheltenham, UK
    if (!card.init(SPI_HALF_SPEED, BUILTIN_SDCARD)) {...
    As far as I know BUILTIN_SDCARD is used for the "BuiltIn" Cards on T3.5,T3.6 and T4.1.

  9. #9
    Junior Member
    Join Date
    Jan 2022
    The Teensy 4.0 supports the standard SD card library for Arduino with the dedicated SDcard pinout using the connector on the bottom of the board Teensy. You can set chipselect as follows:

    const int chipSelect = BUILTIN_SDCARD;

    I use this for testing the SDcard slot when I build the boards.

  10. #10
    Junior Member
    Join Date
    Jan 2022
    thank you all for your support! really!
    unfornutaly i won't have time today to check it because of other urgent projects but i will definetly try on monday and i will report back

  11. #11
    Junior Member
    Join Date
    Jan 2022
    ok, i've tested again with @cburgess129 script (had to download this additional library for it and it didn't work
    then i've connected an external sd-reader via SCK(13) MISO(12) MOSI(11) CS(10) and set chipSelect=10 and it worked! (with the same SD-Card)

    i don't know why but ... hey i now have a working sd-card
    thank you all for your support

    @cburgess129 i won't need a new one, because it's just for development

  12. #12
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    SDIO not working? Seems like the SDIO adapter may have wiring issue.

    See this post and following to confirm proper wiring: T4-SDIO-SD-Card-quot-initialization-failed

    Paul made a simple sketch in Beta to validate wire location and pin function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts