Conflict between WiFiManager and SdFat

(Context) I'm creating demo code to test out a feature that is to be implemented into a bigger piece of code and was testing out downloading and saving API requests with the HTTPClient, WiFi and SdFat libraries which worked successfully. However, as the code is going to be running on a portable device, it made sense to create a method of changing the connected network if required by the user. I then looked into replacing the WiFi library with the WiFiManager library to provide a configuration portal.

The problem is, attempting to merge WiFiManager code snippets to replace code relying on the WiFi library, the error Compilation error: 'File' does not name a type; did you mean 'SdFile'? appears when compiling. I have traced this down to a conflict between the SdFat library and WiFiManager which supposedly cannot be used at the same time as commenting out #include <WiFiManager.h> resolves the issue. Is there an easy way to use both libraries at the same time or should I resort to using the default SD library? Any help is appreciated!

Code used to test the conflict (modified SoftwareSpi example code from the SdFat library):

#include <WiFiManager.h>
#include "SdFat.h"
//#include <HTTPClient.h>
//#include <SPI.h> // include the SPI library

#if SPI_DRIVER_SELECT == 2  // Must be set in SdFat/SdFatConfig.h

// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
// 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
#define SD_FAT_TYPE 0
//
// Chip select may be constant or RAM variable.
const uint8_t SD_CS_PIN = 10;
//
// Pin numbers in templates must be constants.
const uint8_t SOFT_MISO_PIN = 12;
const uint8_t SOFT_MOSI_PIN = 11;
const uint8_t SOFT_SCK_PIN  = 13;

// SdFat software SPI template
SoftSpiDriver<SOFT_MISO_PIN, SOFT_MOSI_PIN, SOFT_SCK_PIN> softSpi;
// Speed argument is ignored for software SPI.
#if ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SD_SCK_MHZ(0), &softSpi)
#else  // ENABLE_DEDICATED_SPI
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SD_SCK_MHZ(0), &softSpi)
#endif  // ENABLE_DEDICATED_SPI

SdFat sd;
File file;

void setup() {

}
//------------------------------------------------------------------------------
void loop() {}
#else  // SPI_DRIVER_SELECT
#error SPI_DRIVER_SELECT must be two in SdFat/SdFatConfig.h
#endif  //SPI_DRIVER_SELECT

Sorry if I've done something incorrectly as this is my first time on the Arduino forum : )

what board did you select in Tools menu?

I have selected the "DOIT ESP32 DEVKIT V1"

are those SPI pins correct? those are SPI pins used on Uno.

btw. WiFiManager doesn't replace WiFi. so try to include WiFi.h

The sketch is example code that came with the library and I only used it to demonstrate the issue. The sketch simply demonstrates how to use software SPI pins instead of the hardware SPI pins already present on the ESP32 which is why the pins in the sketch do not match with the physical SPI pins on the ESP32. I don't believe that the pins are the source of the issue as I have other sketches where I get the same error regardless of whether I am changing the SPI pins.

Including WiFi.h did not resolve the issue as the same Compilation error: 'File' does not name a type; did you mean 'SdFile'? still comes up.

and with WiFiManager include it compiles for the esp32?

No, compiling with the WiFiManager library included in the sketch just results in the aforementioned error which appears to be a conflict with File file, therefore unsuccessfully compiling. File file is required to use the SdFat library.

sorry for the typo. I want to know if without the WiFiManager include it compiles for the esp32?

Yes, without WiFiManager it compiles perfectly fine.

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