Wemos D1 Mini + micro SD shield
Posted: Thu Nov 23, 2017 7:59 pm
Hi.
I just received a couple of wemos D1 mini compatible SD-card shields.
As a first test I was trying to run a couple of demo programs. see below.
The issue is, that the code compiles fine and uploads to the wemos D1, however only if the SD-shield is not connected.
If I install the shield, a connection to the wemos can't be established.
Any thoughts on that would be much appreciated.
p.s. I tried it from Arduino IDE and via Platformio... same same
I just received a couple of wemos D1 mini compatible SD-card shields.
As a first test I was trying to run a couple of demo programs. see below.
The issue is, that the code compiles fine and uploads to the wemos D1, however only if the SD-shield is not connected.
If I install the shield, a connection to the wemos can't be established.
Any thoughts on that would be much appreciated.
p.s. I tried it from Arduino IDE and via Platformio... same same
Code: Select all
/*
* Micro SD Shield - Read/Write
*
* This example shows how to read and write data
* to and from an SD card file
*
* The WeMos Micro SD Shield uses:
* D5, D6, D7, D8, 3V3 and G
*
* The shield uses SPI bus pins:
* D5 = CLK
* D6 = MISO
* D7 = MOSI
* D8 = CS
*
* The SD card library uses 8.3 format filenames
* and is case-insensitive.
* eg. IMAGE.JPG is the same as image.jpg
*
* created Nov 2010 by David A. Mellis
* modified 9 Apr 2012 by Tom Igoe
*
* This example code is in the public domain.
* https://github.com/esp8266/Arduino/blob/master/libraries/SD/examples/ReadWrite/ReadWrite.ino
*/
#include "SPI.h"
#include "SD.h"
const int chipSelect = D8;
File myFile;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect.
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
/* open the file.
* note that only one file can be open at a time
*/
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop()
{
// nothing happens after setup
}