Download file from SD card to device using ESP8266

I’ve been researching a method for downloading a file from an SD card using and adapting the emonESP web interface of the ESP8266.

It’s an ESP12S connected to a microSD card for datalogging.

Can someone point me in the right direction?

Thanks,

Daniel

ESPAsyncWebServer

or if you have the Arduino/ESP8266 configured to your Arduino IDE, you should find under “examples” SDWebServer (examples.ESP8266WebServer.SDWebServer. This is the synchronous version of the same.

With either, you can upload and download from your device (I use a windows PC). In addition to a file manager, it has the ACE editor, which is a fantastic browser based editor.

For example, you can edit a HTML/Javascript file from the SD, Save it to the SD, load the file (or refresh) from another window and run it. It’s a very nice development environment for ESP/AJAX applications.

Perfect, thanks.

I’m making my way through the ESPAsyncWebServer sketch and downloading libraries, I’m stuck at the MYWIFI.h library. How does it work? The example I’ve found seems to be conflicting with the opening SSID and Password lines.
EDIT: Resolved by editing the SSID names so they match up between the MYWIFI.h library and opening lines of main sketch.

Yeah, that’s just a simple way to keep my personal wifi credentials out of the code I have on github. Ordinarily I use WIFImanager to maintain that, as I do in IoTaWatt, but WIFImanager uses the sync version of ESP8266WebServer which cannot coexist with the asynchronous version. I need to resolve that before I can go async with IoTaWatt, but it I don’t expect it to be easy.

I’m having plenty of difficulty merging emonESP and ESP8266WebServer/ESPAsyncWebServer.
This is going to take some time.

I decided tonight on my method. I’m merging emonESP with the SDwebserver sketch. I’m making progress. I have emonESP running with the SD card libraries and the SD card is connected correctly, ‘initialised’, waiting to be accessed…

I think I need to modify the emonESP index.html to create a button to download a file. As I understand it, the SDWebServer sketch relies on ‘handlers’ to perform functions, such as reading/writing and creating files and directories. So I need to relate a button on a html page to a ‘handler’ to enable a download of a specific file?

Just checking I’m on the right path… Tomorrow I’ll have my microSD card adaptor and be able to figure out how the SDWebServer example works, I think, if I look in the right places…