Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

SD card support #422

Closed
psbaltar opened this issue Jan 18, 2019 · 1 comment
Closed

SD card support #422

psbaltar opened this issue Jan 18, 2019 · 1 comment

Comments

@psbaltar
Copy link

What new integration would you wish to have?

SD card component for use in other components

If possible, provide a link to an existing library for the integration:
Arduino SD library (SD.h) https://github.com/arduino-libraries/SD

Please describe your use case for this integration and alternatives you've tried:

I'm trying to use an SD card to store scripts for addressable LED animations.

At the moment, the Arduino SD library can't be used with esphomelib because it conflicts with the esp8266 SPIFFS library. Defining FS_NO_GLOBALS would resolve the issue. I added #define FS_NO_GLOBALS to my project and I'm able to compile with SD.h included. Everything in my project seems to be working correctly.

It'd be nice to have at least the define added officially. But what are your thoughts on having a proper SD component?

Additional context:
ESPAsyncWebServer uses the esp8266 SPIFFS library (FS.h). However, both FS and the Arduino SD library (SD.h) define a File class, so they can't coexist by default. see esp8266/Arduino#1524

FS has a FS_NO_GLOBALS flag as a workaround for the namespace conflict. ESPAsyncWebServer is compatible with the flag. see
me-no-dev/ESPAsyncWebServer#112

Since esphomelib uses ESPAsyncWebServer, the FS_NO_GLOBALS flag needs to be set to use the SD library. As far as I can tell, esphomelib doesn't use SPIFFS calls anywhere. So there shouldn't be a need to do anything other than adding the define to resolve the coexistence problem.

@OttoWinter
Copy link
Member

You can edit the global build flags by editing the <NODE_NAME>/platformio.ini file. In the top section, you can add build flags in build_flags

For example

build_flags = -DFS_NO_GLOBALS

As the user would not use SD library directly anyway, this would not need to be an integration.

@esphome esphome locked and limited conversation to collaborators Jun 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants