How to mount a sd card to adafruit huzzah esp8266 breakout?
Posted: Sat Dec 08, 2018 11:07 pm
Hello,
I want to build a sd card web server on this huzzah breakout, so first I'm trying to mount the sd card to this module. The code is the arduino's example code, I only changed the CS pin from GPIO4 to GPIO15 which is the CS pin of the module.
But the IDE always told me it failed to upload the code:
Then I did some research and found that GPIO15 of this module controls the boot mode and if it's high then the module will fail the uploading. I wonder how should I avoid this problem like changing the CS pin of this module?
I want to build a sd card web server on this huzzah breakout, so first I'm trying to mount the sd card to this module. The code is the arduino's example code, I only changed the CS pin from GPIO4 to GPIO15 which is the CS pin of the module.
Code: Select all
/*
Listfiles
This example shows how print out the files in a
directory on a SD card
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
modified 2 Feb 2014
by Scott Fitzgerald
This example code is in the public domain.
*/
#include <SPI.h>
#include <SD.h>
File root;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
if (!SD.begin(15)) { //Originally it's 4
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
root = SD.open("/");
printDirectory(root, 0);
Serial.println("done!");
}
void loop() {
}
void printDirectory(File dir, int numTabs) {
while (true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
break;
}
for (uint8_t i = 0; i < numTabs; i++) {
Serial.print('\t');
}
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numTabs + 1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
}
}
But the IDE always told me it failed to upload the code:
Code: Select all
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
Then I did some research and found that GPIO15 of this module controls the boot mode and if it's high then the module will fail the uploading. I wonder how should I avoid this problem like changing the CS pin of this module?