I've been fighting with libraries for a few days trying to get this to compile but it seems I'm getting library conflicts between the "ESP8266SdFat" library (installed by the hardware library) and the "SdFat_-_Adafruit_Fork" (required by the AdafruitIO_Wifi library).
My project is using the SD card on a 128x128 TFT breakout to load a picture to the screen and it also downloads small data packages from Adafruit IO. Displaying the picture and interfacing with Adafruit IO works great on its own but the problem has arisen when I put both functions in the same sketch.
Below is my code and error message. The examples using AdafruitIO_Wifi and the examples using Adafruit_ImageReader both worked well; compiled and uploaded to the hardware with no problem.
BUT now I'm getting 'Multiple libraries were found for "SdFat.h"' and "'File' is already declared in this scope".
Why is there a SDFat library in the ESP8266 files anyway? Can it be disabled so I can use the other which I have already installed?
CODE:
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions
#include <AdafruitIO_WiFi.h>
//Adafruit IO key.
#define IO_USERNAME "ME"
#define IO_KEY "NOPE"
//Wifi Info
#define WIFI_SSID "NOPE"
#define WIFI_PASS "NOPE"
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
// Comment out the next line to load from SPI/QSPI flash instead of SD card:
#define USE_SD_CARD
#define SD_CS 16 // SD card select pin
#define TFT_CS 0 // TFT select pin
#define TFT_DC 15 // TFT display/command pin
#define TFT_RST 4 // Or set to -1 and connect to Arduino RESET pin
#define LED_PIN 13 // Pin driven by Adafruit IO download
#if defined(USE_SD_CARD)
SdFat SD; // SD card filesystem
Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
#else
// SPI or QSPI flash filesystem (i.e. CIRCUITPY drive)
#if defined(__SAMD51__) || defined(NRF52840_XXAA)
Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS,
PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
#else
#if (SPI_INTERFACES_COUNT == 1)
Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
#else
Adafruit_FlashTransport_SPI flashTransport(SS1, &SPI1);
#endif
#endif
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem filesys;
Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
Adafruit_Image img; // An image loaded into RAM
// set up the 'digital' feed
AdafruitIO_Feed *digital = io.feed("digital");
void setup(void) {
pinMode(LED_PIN, OUTPUT);
ImageReturnCode stat; // Status from image-reading functions
Serial.begin(115200);
tft.initR(INITR_144GREENTAB); // Initialize screen
// The Adafruit_ImageReader constructor call (above, before setup())
// accepts an uninitialized SdFat or FatFileSystem object. This MUST
// BE INITIALIZED before using any of the image reader functions!
Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
// SD card is pretty straightforward, a single call...
if(!SD.begin(SD_CS, SD_SCK_MHZ(10))) { // Breakouts require 10 MHz limit due to longer wires
Serial.println(F("SD begin() failed"));
for(;;); // Fatal error, do not continue
}
#else
// SPI or QSPI flash requires two steps, one to access the bare flash
// memory itself, then the second to access the filesystem within...
if(!flash.begin()) {
Serial.println(F("flash begin() failed"));
for(;;);
}
if(!filesys.begin(&flash)) {
Serial.println(F("filesys begin() failed"));
for(;;);
}
#endif
Serial.println(F("OK!"));
tft.fillScreen(0); // clear screen
reader.drawBMP("/lily128.bmp", tft,0,0); //draw the background
tft.setTextWrap(true);
tft.setTextColor(ST77XX_WHITE);
tft.setTextSize(1);
tft.println("Beginning...");
// set up a message handler for the 'digital' feed.
// the handleMessage function (defined below)
// will be called whenever a message is
// received from adafruit io.
digital->onMessage(handleMessage);
// connect to io.adafruit.com
Serial.print("Connecting to Adafruit IO");
io.connect();
// wait for a connection
while(io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
// we are connected
Serial.println();
Serial.println(io.statusText());
digital->get();
}
void loop() {
io.run();
//RECEIVING (current):
//download digital 1 or 0 from Adafruit IO
//sets LED PIN to that value
}
// this function is called whenever an 'digital' feed message
// is received from Adafruit IO. it was attached to
// the 'digital' feed in the setup() function above.
void handleMessage(AdafruitIO_Data *data) {
Serial.print("received <- ");
tft.println("msg received.");
if(data->toPinLevel() == HIGH)
Serial.println("HIGH");
else
Serial.println("LOW");
digitalWrite(LED_PIN, data->toPinLevel());
}
ERROR:
In file included from C:\Users\Me\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.2\libraries\ESP8266WiFi\src/CertStoreBearSSL.h:26:0,
from C:\Users\Me\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.2\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.h:30,
from C:\Users\Me\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.2\libraries\ESP8266WiFi\src/WiFiClientSecure.h:41,
from C:\Users\Me\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.2\libraries\ESP8266WiFi\src/WiFiServerSecure.h:20,
from C:\Users\Me\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.2\libraries\ESP8266WiFi\src/ESP8266WiFi.h:41,
from C:\Users\Me\Documents\Arduino\libraries\Adafruit_IO_Arduino\src/wifi/AdafruitIO_ESP8266.h:19,
from C:\Users\Me\Documents\Arduino\libraries\Adafruit_IO_Arduino\src/AdafruitIO_WiFi.h:37,
from C:\Users\Me\Documents\Arduino\WirelessPictureFrame\WirelessPictureFrame.ino:6:
C:\Users\Me\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.2\cores\esp8266/FS.h:258:11: error: 'File' is already declared in this scope
using fs::File;
^
Multiple libraries were found for "SdFat.h"
Used: C:\Users\Me\Documents\Arduino\libraries\SdFat_-_Adafruit_Fork
Not used: C:\Users\Me\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.6.2\libraries\ESP8266SdFat
exit status 1
Error compiling for board Adafruit Feather HUZZAH ESP8266.