• I'm using a puck.js v2 + esp8266 (ESP-01) module on Serial1 to serve files stored on an SD-card.

    While I understand that this will never be a super fast file transfer method, I wonder what kind of speed could be expected? I'm currently getting between 600-700 bytes/s, and increasing the UART speed from 115200->460800 didn't really make a difference so I suspect that the UART is not the bottleneck.

    Example code:

    var wifi;
    
    function mountSDCard() {
      SPI2.setup({mosi:D30, miso:D28, sck:D29, baud: 8000000});
      E.connectSDCard(SPI2, D31);
      try {
        console.log(require("fs").readdirSync());
      } catch(error){
        console.log(error);
      }
      E.setFlags({unsyncFiles:1})
    }
    
    function onInit() {
      Bluetooth.setConsole(true);
      mountSDCard();
    
      Serial1.setup(460800, { rx: D1, tx : D2 });
      setupWifi();
    }
    
    
    function setupWifi() {
      var WIFI_NAME = "UseThisOneMom";
      var WIFI_PASS = "asdf";
      wifi = require("ESP8266WiFi_0v25").connect(Serial1, function(err) {
        if (err) throw err;
        console.log("Connecting to WiFi");
        wifi.connect(WIFI_NAME, WIFI_PASS, function(err) {
          if (err) throw err;
          console.log("Connected");
          // Now you can do something, like an HTTP request
          require("http").createServer(onPageRequest).listen(8080);
        });
      });
    }
    
    function onPageRequest(req, res) {
      var a = url.parse(req.url, true);
      var f = E.openFile(a.pathname, "r");
      if (f !== undefined) {
        res.writeHead(200, {'Content-Type': 'text/plain'});
        f.pipe(res); // streams the file to the HTTP response
      } else {
        res.writeHead(404, {'Content-Type': 'text/plain'});
        res.end("404: Page "+a.pathname+" not found");
      }
    }
    
  • Found this comment at Internet / Transferring files:

    Note: by default .pipe will use a relatively small chunk size (the
    amount of data read and written in one go). Replacing f.pipe(res) with
    f.pipe(res, {chunkSize:512}); will drastically increase file transfer
    speeds as it better matches the block size of SD cards.

About

Avatar for AkosLukacs @AkosLukacs started