Hello! I have had a problem with implementing a MicroSD card reader to my ESP8266 for a long time. I bought the module in picture below and connected it as follows:
CS -> D8
SCK -> D5
MOSI -> D6
MISO -> D7
VCC -> 3V
GND -> G
Unfortunately, after running the example SD -> Files / ReadWrite
the same message shows "Initializing SD card ... initialization failed!"
. I tried to plug the pins into the S1, SC, SD and S0, but it did not help either. Trying to use other libraries or even buying a new NodeMCU and replacing the microSD card reader with new SD card reader also doesn't help. I have no idea where the problem may be, so I'm asking for help.
power it with 5 V
I did it before but it didnt work either.
VCC->VIN while connected via usb cable to pc and still same error message.
depending on the code you are using and how the SPI-interface is configured by that code it might be that the code exepcts the SPI-interface-pins on different IO-numbers
I have had similar problems in the past. But I don't remember the details.
Best thing is that you post the demo-code that you use as a code-section.
How to post code as a code-section is described here
best regards Stefan
D8 equals to GPIO-pin 15 which must be low at boot. Otherways the boot fails.
See here
try D1 (GPIO5) für SS instead of D8 (GPIO15)
Depending on how you power your microcontroller on the Vin-pin there can be a voltage even higher as 5V. It is the Inputvoltage that is regulated down after Vin pin.
Depending on how much data you want to store it might be sufficient to use the internal flash-memory to store the data.
Depending on your project if your ESP8266 is connected to your local WiFi another option might be to send the data through UDP-messages to a computer or a rasperry Pi that receives the UDP-messages and stores the messages in his memory
best regards Stefan
Ok so here is example that im using.
[code]
/*
SD card basic file example
This example shows how to create and destroy an SD card file
The circuit:
SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
created Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
*/
#include <SPI.h>
#include <SD.h>
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
if (SD.exists("example.txt")) {
Serial.println("example.txt exists.");
} else {
Serial.println("example.txt doesn't exist.");
}
// open a new file and immediately close it:
Serial.println("Creating example.txt...");
myFile = SD.open("example.txt", FILE_WRITE);
myFile.close();
// Check to see if the file exists:
if (SD.exists("example.txt")) {
Serial.println("example.txt exists.");
} else {
Serial.println("example.txt doesn't exist.");
}
// delete the file:
Serial.println("Removing example.txt...");
SD.remove("example.txt");
if (SD.exists("example.txt")) {
Serial.println("example.txt exists.");
} else {
Serial.println("example.txt doesn't exist.");
}
}
void loop() {
// nothing happens after setup finishes.
}
[/code]
It says that i should connect MOSI to pin 11, which I can't find on Pinout Reference. I tried to connect SCK to D1 but it still shows same message. I even tried to connect it via SDD1, SDCMD,SDD0 and SDCLK but it didnt work either.
Depending on how much data you want to store it might be sufficient to use the internal flash-memory to store the data.
I only need to detect how many cars crossed the streets during the day with time of detection. Unfortunately, my device will not have a permanent connection to the internet then.
How many cars will this estimated be?
20 cars?
200 cars?
2000 cars?
20000 cars?
I haven't done any calculations about that.
You can configure an ESP8266 to different memeory schemes where memory for
program / data can have different sizes
Depending on the overall size of the flash-chip this can be pretty much
The minimum is flashsize common for nodeMCU is 1MB and then can be configured to have an internal Filesystem of 512 kB
Here is a code that detects the flash-size
void setup(void) {
Serial.begin(115200);
uint32_t realSize = ESP.getFlashChipRealSize();
uint32_t ideSize = ESP.getFlashChipSize();
FlashMode_t ideMode = ESP.getFlashChipMode();
Serial.printf("Reale Flash ID: %08X\n", ESP.getFlashChipId());
Serial.printf("Reale Flash groesse: %u", realSize);
Serial.print(" Byte\n\n");
Serial.printf("In der IDE hinterlegte Flash groesse: %u", ideSize);
Serial.print(" Byte\n");
Serial.printf("In der IDE hinterlegte Flash geschwindigkeit: %u\n", ESP.getFlashChipSpeed());
Serial.printf("In der IDE hinterlegter Flash Modus: %s\n\n", (ideMode == FM_QIO ? "QIO" : ideMode == FM_QOUT ? "QOUT" : ideMode == FM_DIO ? "DIO" : ideMode == FM_DOUT ? "DOUT" : "UNKNOWN"));
if(ideSize != realSize) {
Serial.println("Flash konfiguration ist falsch!\n");
} else {
Serial.println("Flash konfigguration ist korrekt.\n");
}
}
void loop() {
}
with 4MB this can be configured to 3MB filesystem
If each timestamp needs four bytes this means
space for storing 750.000 passings
So instead of storing the data on an SD-card you could store it inside the LittleFS
of the ESP8266 and transmitt the data wireless through UDP-messages to a computer
best regards Stefan
you have MISO and MOSI swapped
D6 is MISO
D7 is MOSI
It might actually be good idea to try it on FS, thanks for advice. However, I know that using microsd module would be usefull in other projects so I would still like to solve this problem but Im running out of ideas.
you have MISO and MOSI swapped
D6 is MISO
D7 is MOSI
I swapped it and it shows same problem.
Could it be my microSD card problem? I bought it last week from the store. It has 16GB and runs good on my PC with adapter microSD->SD. I looked on settings but card is also formated to FAT32.
and 5 V?
Yes
try the CardInfo example
sorry. you use the esp8266 SD library, which doesn't have that example
Ok, i don't know what happend but after compiling this code it somehow worked.
So i decied to compare this code with esp8266 SD "Files" example, and after running this example, it also started working.
I don't know what could be causing this error but it works so far so thank you all for your help
I have same issue. But I couldn't solve it. All of my equipments and components are new. I have ESP8266-12E NodeMCU, Arduino SD card module and 32gb FAT32 SD card. I have did the pin connections but I couldn't store my data to SD card. My friend also have same components and same codes but he could do it. How you solved it?
Why don't you ask your friend?
Why don't you compare each and every detail of your setup with your friends setup?
How should asking in a forum in such a general way ever be able to solve such a problem?
You have to provide detailed information about your hardware.
The microcontroller-world is not superstandardised like USB-devices
you have to take care of more details than just
"does the plug fit into the socket?"
best regards Stefan
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.