Serve files from an SD-card using esphttpd.
Posted: Tue Apr 14, 2015 1:15 pm
Okay, over the weekend I finished a proof-of-concept to see if I could: I added the capability to serve files from FAT-formatted SD-cards to esphttpd. It uses a GPIO-based SPI driver to access the SD-card in FAT mode (hardware SPI also is implemented but very flaky) and Elm-chans FatFS to read the filesystem.
The SD-card is connected to the following I/O pins. Both normal-sized SD as well as micro-SD as well as SDHC cards are supported, although not all cards seem to implement the SPI protocol in the way I expect them to - a few of my cards just won't work. Also, because I use bitbanging, everything is gonna be very slow - expect speeds of about 20K/second.
(See eg here for pin reference)
CD/DAT3/CS - GPIO5
CMD/DI - GPIO13
CLK/SCLK - GPIO14
DAT0/DO - GPIO12 (may need an 10K pullup to 3.3V)
VSS1 & VSS2 - GND
VDD - 3.3V
(If you use an ESP12, take care: on all ESP12s I have, the silkscreen has GPIO4 and GPIO5 switched around.)
If you then go to the root of the webserver, it should serve up a directory listing of what's in the SD-card; you can then browse around.
Get it by pulling http://git.spritesserver.nl/esphttpd.git and doing a git checkout fatfs. Because some people will want to try it without compiling it, I've also made an exception to my policy and provided precompiled binaries. Get them here. Also make sure to flash webpages.espfs to 0x12000.
One final note: because the root now is the root of the SD-card, the wifi connection page isn't automatically loaded anymore. Go to. http://[ip]/wifi/wifi.tpl to configure WiFi.
The SD-card is connected to the following I/O pins. Both normal-sized SD as well as micro-SD as well as SDHC cards are supported, although not all cards seem to implement the SPI protocol in the way I expect them to - a few of my cards just won't work. Also, because I use bitbanging, everything is gonna be very slow - expect speeds of about 20K/second.
(See eg here for pin reference)
CD/DAT3/CS - GPIO5
CMD/DI - GPIO13
CLK/SCLK - GPIO14
DAT0/DO - GPIO12 (may need an 10K pullup to 3.3V)
VSS1 & VSS2 - GND
VDD - 3.3V
(If you use an ESP12, take care: on all ESP12s I have, the silkscreen has GPIO4 and GPIO5 switched around.)
If you then go to the root of the webserver, it should serve up a directory listing of what's in the SD-card; you can then browse around.
Get it by pulling http://git.spritesserver.nl/esphttpd.git and doing a git checkout fatfs. Because some people will want to try it without compiling it, I've also made an exception to my policy and provided precompiled binaries. Get them here. Also make sure to flash webpages.espfs to 0x12000.
One final note: because the root now is the root of the SD-card, the wifi connection page isn't automatically loaded anymore. Go to. http://[ip]/wifi/wifi.tpl to configure WiFi.