Yes. Please share the code.
@peekay123 and @kennethlimcp, I will test the SD by itself. If that works, then I’m screwing something up in the config of the LCD AND the SD on the same SPI connection.
Yes. Please share the code.
@peekay123 and @kennethlimcp, I will test the SD by itself. If that works, then I’m screwing something up in the config of the LCD AND the SD on the same SPI connection.
@peekay123 and @kennethlimcp I have tested with your code and nothing else and I get the same behavior.
In my first attempt I get an error:
But after I eject and push the SD card in again the test is successful:
Is there a way to “automate” the pull out and put in of the SD Card? Any way to fake this so that the user doesn’t have to do it?
It will have to involve cutting the power from the SD card. Try formatting your card as FAT32 on a PC and try the test again.
@sazp96, I did not have to remove and re-insert the microSD in my tests. It may be your microSD type or the formatting (use SDFormatter) which should be FAT32 like @kennethlimcp indicated.
From @kennethlimcp’s code, I know that my card type is: SD1. According to windows it is formatted as FAT32
I will try SDFormatter right now. Thanks guys!
Should I turn on the “FORMAT SIZE ADJUSTMENT” feature?
@sazp96, I would say format with default options to start with.
@sazp96, I am not sure what SD1 type is but what “class” is your microSD (Class 6, 10)? Is it a newer microSD card?
It is a newer recently bought SD card. Do you know how can I check that?
From @kennethlimcp is see three types:
SD_CARD_TYPE_SD1
SD_CARD_TYPE_SD2
SD_CARD_TYPE_SDHC
Is there a preference between those types?
No i don’t think it really matters
@sazp96, if it’s newer then it should be fine.
Got it. Just as FYI. Three of my cards are SDHC. And one is SD1. But it doesn’t seem to make a difference.
Which SD breakout board are you using? Make sure only the SD card is connected and how are you powering the Photon?
@kennethlimcp I’m using the SD breakout board that comes with Adafruit’s 3.5 TFT LCD Screen. Both the Photon and the LCD/SD are powered by a 5V 2Amp power source.
After doing a quick format, I keep getting the inconsistent errors. I receive an “Initializing error: CMD0”. Then after I eject and plug in the card again it works.
I found some info about the SDHC 4G cards that I have.
SDHC Logo
SD High Capacity (SDHC™) card is an SD™ memory card based on the SDA 2.0 specification.
SDHC capacities range from 4GB to 32GB
Default Format: FAT32
Because SDHC works differently than standard SD cards, this new format is NOT backwards compatible with host devices that only take SD (128MB - 2GB) cards. Most readers and host devices built after 2008 should be SDHC compatible.
To ensure compatibility, look for the SDHC logo on cards and host devices (cameras, camcorders, etc.)
I will try different types of formatting to see if that is the issue.
Update: According to Adafruit, all their breakout boards are SDHC compatible.:
Please note! This is an SDHC card, and may not work with very old projects or products that only support SD cards. All of the Adafruit projects and products use SD/HC-compatible code. Make sure you can use this card before purchasing for non-Adafruit products. The brand itself may vary but we use only quality name-brand from reputable suppliers
@sazp96, all my microSD are SDHC types and I have no problems.
@peekay123, do you know if there is a SD.end()
method in the SD library. I don’t see it.
I just remember that was the recomendation I got from the Adafruit forum:
Re: MicroSD sometimes fails to start on TFT screens
by adafruit_support_rick on Mon Jun 15, 2015 8:28 am
3.3V logic shouldn't matter.
We don't do anything with the SPI signals except pass them through a level-shifter. Otherwise, they go straight to the card. This is probably the sort of thing you have to fix in software. If it doesn't initialize, call sd.end() and try initializing again.
I found the method in a Adafruit’s Github here.
SD.cpp:
//call this when a card is removed. It will allow you to inster and initialise a new card.
void SDClass::end()
{
root.close();
}
Could this be it? I will git it a try and report back.
@sazp96, that is not in the library I gave you so stick to the Adafruit one for your tests
Update: This issue has been solved. I had a “soft” shorticircuit in my PCB that was causing problem to the LITE pin of Adafruit’s LCD.
Thank you for all the help @peekay123 a @kennethlimcp!!
Hi @peekay123 would you be able to share a link to this SD card library for the photon please? I can’t see the link anywhere… Trying to get the VS1053 library working with the photon, and think there are some compatibility issues caused by the SD card library used with it (i.e. it’s using a Core, not a Photon SD card library). Thanks for any help.
I have pushed the working SD library by @peekay123 here - https://github.com/kennethlimcp/particle-examples
You will need CLI to compile it