• @user73896
    I mean the javascript you used to get the spi SD card working, and the wiring and pins you used - perhaps even a photo!

  • @Wilberforce @jumjum
    ESP32 Board: widora v5.0https://world.taobao.com/item/5382098013­68.htm
    SD Card Adapter: Catalex Micro SD Card Adapterhttps://detail.tmall.com/item.htm?id=416­90559539&spm=a1z09.2.0.0.816EuT&_u=61fd9­1teef0
    Wiring:

    | Orange |  Black |  Blue  | White  | Yellow | Green | 
    | 3V3    |  GND   |  IO5   | IO18   | IO23   | IO19  | ESP32 Board      |
    | VCC    |  GND   |   CS   |  SCK   | MOSI   | MISO  | SD Card Adaptern |
    

    Esrupino: master branch
    env vars: export USE_FILESYSTEM=1
    IDE: ESPRUINO WEB IDE
    Javascript:

    /*
    | SPI  | MOSI | MISO | CLK | SS/CS | PLATFORM      |
    | SPI1 | 13   | 12   | 14  | 15    | ESP8266/ESP32 |
    | SPI2 | 23   | 19   | 18  | 5     | ESP32 only    |
    */
    var opts = {sck:18, miso:19, mosi:23};
    SPI2.setup(opts);
    
    E.connectSDCard(SPI2, 5 /*CS*/);
    var fs = require("fs");
    
    // list files on SD card
    console.log("\nFiles on SD Card -->\n");
    console.log(fs.readdirSync());
    // read a exitsting file on SD card
    console.log("\nContent of example.txt : -->\n");
    console.log(fs.readFileSync("example.txt­"));
    // creat a file
    fs.writeFile("test.txt", "Hello world!");
    fs.appendFileSync("test.txt", " I'm Esrpusino.");
    // list files on SD card
    console.log("\nFiles on SD Card -->\n");
    console.log(fs.readdirSync());
    // read text.txt created before on SD card
    console.log("\nContent of test.txt : -->\n");
    console.log(fs.readFileSync("test.txt"))­;
    // list files on SD card
    console.log("\nFiles on SD Card -->\n");
    console.log(fs.readdirSync("mydir"));
    // read text2.txt in /mydir on SD card
    console.log("\nContent of test2.txt : -->\n");
    console.log(fs.readFileSync("mydir/test2­.txt"));
    

    Content of SD Card before running the codes:
    /EXAMPLE.txt
    /mydir/test2.txt

    output in left hand side of WEB IDE:

    >WARNING: jshReset(): To implement - reset of i2c
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v91.2721 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    >
    Files on SD Card -->
    [
      "System Volume Information",
      "EXAMPLE.TXT",
      "._.Trashes",
      ".Trashes",
      ".Spotlight-V100",
      "mydir"
     ]
    Content of example.txt : -->
    A1234567890abcdefghigklmnopqrstuvwxyz
    Files on SD Card -->
    [
      "System Volume Information",
      "EXAMPLE.TXT",
      "._.Trashes",
      "test.txt",
      ".Trashes",
      ".Spotlight-V100",
      "mydir"
     ]
    Content of test.txt : -->
    Hello world! I'm Esrpusino.
    Files on SD Card -->
    [
      ".",
      "..",
      "test2.txt"
     ]
    Content of test2.txt : -->
    Hello, I'm in directory /mydir.
    =undefined
    

    2 Attachments

    • IMG_1805.jpg
    • IMG_1806.jpg
About

Avatar for Aifer @Aifer started