SD card is not recognized

I use a WeMos D1 board and it's working fine.
I want to use an SD card but I get a mismatch by:

Sd2Card card;
SdVolume volume;
SdFile root;

First I thought there must filled in some parameters but after searching on Internet and the forum I think there's another problem. Who can help me.?
I know I can find a lot in the library SD.h, but I don't know where I can find it.
Greetings Ptr

What does that mean?

Please post a complete sketch that illustrates the problem that you are having

I get this mistake:

  • o - o - o - o - o - o - o
    Meerdere bibliotheken gevonden voor "SD.h"

Gebruikt: C:\Users\Peter\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\SD

Niet gebruikt: C:\Program Files\Arduino\libraries\SD

Bibliotheek SPI op versie 1.0 in map: C:\Users\Peter\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\SPI wordt gebruikt

Bibliotheek SD op versie 2.0.0 in map: C:\Users\Peter\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\SD wordt gebruikt

Bibliotheek SDFS op versie 0.1.0 in map: C:\Users\Peter\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\SDFS wordt gebruikt

Bibliotheek ESP8266SdFat op versie 2.0.2 in map: C:\Users\Peter\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266SdFat wordt gebruikt

exit status 1

'Sd2Card' does not name a type

  • o - o - o - o - o - o - o

And this is the code:

</>
/*
SD card test

This example shows how use the utility libraries on which the'
SD library is based in order to get info about your SD card.
Very useful for testing a card when you're not sure whether its working or not.

The circuit:

  • SD card attached to SPI bus as follows:
    ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila
    ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila
    ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila
    ** CS - depends on your SD card shield or module.
    Pin 4 used here for consistency with other Arduino examples

created 28 Mar 2011
by Limor Fried
modified 9 Apr 2012
by Tom Igoe
*/
// include the SD library:
#include <SPI.h>
#include <SD.h>

#define SD_CS D2
#define SD_SCK D5
#define SD_MOSI D7
#define SD_MISO D6

// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = D2;
#define _cs D2

void setup()
{
pinMode(_cs, OUTPUT);
digitalWrite(_cs, HIGH);
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
</>

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Oke. I misunderstood.

LS
Has someone an answer on my question:

Sd2Card' does not name a type

Thanks Ptrzet

Where did you get the sketch from ?

i had faced the same issue earlier because it wasn't receiving enough power supply from the controller

Hi UKHeliBob
Thanks for your reply.
What I understand the sketch was an example in Arduino IDE.
I found it on the web:
https://www.instructables.com/Arduino-TFT-display-of-bitmap-images-from-an-SD-Ca/.

Hai sha1301
I changed the power supply but I got the same problem during compiling.
Ptrzet

After searching the Internet for " Sd2Card does not name a type" I believe the problem may be occurring because you are using an ESP8266 rather than an Arduino with an AVR processor

As an experiment try changing the board to a Uno and verifying the sketch

Hai UKHeliBob
When I started this question on the forum I was afraid the conclusion was: use an Uno.
I always use the ESP8266 and you always read: compatible with Uno.
But I don't believe it anymore. I'll buy an Uno and try the same sketch.
But it's also possible there are problems because the SD library is changed and that's the reason the example is removed in the IDE. In the SD example 'Read and Write' there is no line with 'Sd2Card card'. I will let you know if it works with the UNO.
Greetings and thanks for your help.
Ptrzet

Start by verifying it with a Uno as the target board. You do not actually need to connect a Uno for this

Hai UKHeliBob
Oke.
Thanks.

It depends on your definition of "compatible".

That's what I learned. :woozy_face:

Please refer the following link:

https://randomnerdtutorials.com/esp32-microsd-card-arduino/

I successfully integrated an SD card with ESP32 based on the libraries and code mentioned in the link given above. I don't think Uno is efficient in handling the SD card since data in sd card mainly deals with String and string manipulation involves a huge chunk of memory for which controllers are not built.

That is not because of the SD card or the SD library. Neither the card nor the library uses the String class. That is a programmer's choice. If that screws things up, it's because the programmer made the choice to use the String class, not because of any feature or aspect of the SD library.

The limitation with the Uno is simpler - it's that the I/O buffer has to reside in RAM. So it uses up a fair portion of the Uno's limited complement of RAM. IIRC, the buffer is 512 bytes.