[SOLVED] Issues with SD.h and ESP8266

I've tried to compile the read/write example in the Arduino IDE using the Wemos D1 Mini.

When I try to compile it, it stops and throws an error pointing to if (!SD.begin(CS_PIN)).

#include <SPI.h>
#include <SD.h>
File myFile;
#define CS_PIN D8

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  Serial.print("Initializing SD card...");
  if (!SD.begin(CS_PIN)) { <====== THROWS ERROR
    Serial.println("initialization failed!");
    return;
  }

The error is:
cannot convert 'SPISettings' to 'uint32_t' {aka 'unsigned int'}

Yet I've used SD.h on my Wemos d1 Mini's in the past without issue.

Any help would be appreciated.

Hi,
You are missing one more closing brace, "}", at the end of your code.

#include <SPI.h>
#include <SD.h>
File myFile;
#define CS_PIN D8

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  Serial.print("Initializing SD card...");
  if (!SD.begin(CS_PIN)) { <====== THROWS ERROR
    Serial.println("initialization failed!");
    return;
  }
}
#include <SPI.h>
#include <SD.h>
File myFile;
#define CS_PIN D8

void setup() {         <== void brace start
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  Serial.print("Initializing SD card...");
  if (!SD.begin(CS_PIN)) {          <== if brace start
    Serial.println("initialization failed!");
    return;
  }       <== if brace end
}         <== void brace end

I don't see any missing braces. If there were I would have been thrown a different error.

But thanks for trying ruilviana.

For what it's worth, the code compiles fine for an Arduino Uno board. Just not for an ESP8266 board.

UPDATE:

I switched to my laptop and the code compiles fine on it for the ESP8266 board, just not on my desktop computer. Strange.....

UPDATE #2:

I found a library that was conflicting with the call to SD.h
Removed the library sdFat.h and everything compiled fine.
Marked as solved.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.