{"id":31921802,"url":"https://github.com/zpg6/esp32-sdcard","last_synced_at":"2025-10-13T22:54:18.407Z","repository":{"id":315771274,"uuid":"1060771659","full_name":"zpg6/esp32-sdcard","owner":"zpg6","description":"A simple example of using embedded-sdmmc-rs to write data to a Micro SD card on ESP32 with Rust and Embassy.","archived":false,"fork":false,"pushed_at":"2025-09-20T15:30:02.000Z","size":337,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-20T17:32:23.511Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zpg6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-20T15:03:02.000Z","updated_at":"2025-09-20T15:30:06.000Z","dependencies_parsed_at":"2025-09-20T17:32:48.995Z","dependency_job_id":"01a26185-dce8-4ddf-b679-a246b96b2dd9","html_url":"https://github.com/zpg6/esp32-sdcard","commit_stats":null,"previous_names":["zpg6/esp32-sdcard"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/zpg6/esp32-sdcard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zpg6%2Fesp32-sdcard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zpg6%2Fesp32-sdcard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zpg6%2Fesp32-sdcard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zpg6%2Fesp32-sdcard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zpg6","download_url":"https://codeload.github.com/zpg6/esp32-sdcard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zpg6%2Fesp32-sdcard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017088,"owners_count":26085984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-13T22:54:16.859Z","updated_at":"2025-10-13T22:54:18.395Z","avatar_url":"https://github.com/zpg6.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESP32 Micro SD Card Example\n\nA simple example of using [`embedded-sdmmc-rs`](https://github.com/rust-embedded-community/embedded-sdmmc-rs) to write data to an SD card on ESP32 with Rust and Embassy.\n\n## What it does\n\n1. Initializes Micro SD card with automatic retries\n2. Creates a random CSV filename in the format of \"ABC12345.CSV\"\n3. Writes the CSV header \"Timestamp,Counter,Value\"\n4. Writes the timestamp and latest counter value to the file every second\n5. Flushes data every 10 counts to ensure the filesystem's directory entry is updated for this file\n\n## Hardware Setup\n\n- ESP32 development board\n- SD card module connected via SPI:\n  - CS: GPIO18\n  - SCK: GPIO19\n  - MISO: GPIO21\n  - MOSI: GPIO23\n\nThere are lots of options for SD card modules. Here are some that we've tested with:\n\n| Link                                                                                                                                      | Image                                                       |\n| ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |\n| [Amazon - HiLetgo 5pcs Micro SD Reader Adapter SPI](https://www.amazon.com/HiLetgo-Adater-Interface-Conversion-Arduino/dp/B07BJ2P6X6)     | \u003cimg src=\"./docs/HiLetgoMicroSDCardReader.jpg\" width=\"200\"\u003e |\n| [Digi-Key - DFRobot Micro SD Connectivity Evaluation Expansion Board](https://www.digikey.com/en/products/detail/dfrobot/DFR0229/6588460) | \u003cimg src=\"./docs/DFR0229_sml.webp\" width=\"200\"\u003e             |\n\n## Usage\n\n1. Complete the pre-requisite installations to setup the ESP32 toolchain\n   - https://github.com/esp-rs/esp-idf-template#prerequisites\n2. Build and run to your ESP32\n\n   ```bash\n   . $HOME/export-esp.sh   # Run each time you open a new terminal\n\n   cargo check             # Verify compilation\n   cargo build             # Build for target\n\n   cargo run -r            # Use espflash to run on your ESP32\n   ```\n\n\u003cbr\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eExpand to see Debug output\u003c/summary\u003e\n\n```\nets Jul 29 2019 12:21:46\n\nrst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)\nconfigsip: 0, SPIWP:0xee\nclk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00\nmode:DIO, clock div:2\nload:0x3fff0030,len:6276\nload:0x40078000,len:15748\nload:0x40080400,len:4\nho 8 tail 4 room 4\nload:0x40080404,len:3860\nentry 0x4008063c\nI (31) boot: ESP-IDF v5.4.1-426-g3ad36321ea 2nd stage bootloader\nI (31) boot: compile time Apr 24 2025 15:52:44\nI (31) boot: Multicore bootloader\nI (34) boot: chip revision: v3.1\nI (37) boot.esp32: SPI Speed      : 40MHz\nI (40) boot.esp32: SPI Mode       : DIO\nI (44) boot.esp32: SPI Flash Size : 4MB\nI (48) boot: Enabling RNG early entropy source...\nI (52) boot: Partition Table:\nI (55) boot: ## Label            Usage          Type ST Offset   Length\nI (61) boot:  0 nvs              WiFi data        01 02 00009000 00006000\nI (67) boot:  1 phy_init         RF data          01 01 0000f000 00001000\nI (74) boot:  2 factory          factory app      00 00 00010000 003f0000\nI (81) boot: End of partition table\nI (84) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=020e0h (  8416) map\nI (94) esp_image: segment 1: paddr=00012108 vaddr=3ffb0000 size=004dch (  1244) load\nI (99) esp_image: segment 2: paddr=000125ec vaddr=40080000 size=01184h (  4484) load\nI (108) esp_image: segment 3: paddr=00013778 vaddr=00000000 size=0c8a0h ( 51360)\nI (131) esp_image: segment 4: paddr=00020020 vaddr=400d0020 size=0b274h ( 45684) map\nI (147) boot: Loaded app from partition at offset 0x10000\nI (147) boot: Disabling RNG early entropy source...\n\n==============================\nESP32 SD Card Counter Example\n==============================\n\nGenerated filename: R2TBDGCM.CSV\nSetting up SPI bus for SD card...\n    SPI bus configured\nInitializing SD Card...\n    SD Card ready - size: 238 GB\n    Volume 0 opened\n    Root directory opened\n    CSV file 'R2TBDGCM.CSV' created\n    CSV header written\nStarting counter loop...\n\nCounter: 1\nCounter: 2\nCounter: 3\nCounter: 4\nCounter: 5\n```\n\n\u003c/details\u003e\n\u003cbr\u003e\n\u003cdetails\u003e\n\u003csummary\u003eExpand to see R2TBDGCM.CSV file we captured\u003c/summary\u003e\n\n```csv\nTimestamp,Counter,Value\n234,count,1\n1240,count,2\n2245,count,3\n3250,count,4\n4256,count,5\n5261,count,6\n6266,count,7\n7272,count,8\n8278,count,9\n9284,count,10\n10308,count,11\n11317,count,12\n12323,count,13\n13332,count,14\n14336,count,15\n15340,count,16\n16344,count,17\n17348,count,18\n18352,count,19\n19356,count,20\n20375,count,21\n21384,count,22\n22389,count,23\n23394,count,24\n24400,count,25\n25405,count,26\n26410,count,27\n27416,count,28\n```\n\n\u003c/details\u003e\n\n\u003cbr\u003e\n\n## Formatting SD Cards\n\nWe recommend using a tool like [Rufus](https://rufus.ie/) to format the SD card.\n\n| Step                                                                                                               | Screenshot                                                                                                                                             |\n| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| 1. Download and install Rufus from https://rufus.ie/                                                               | ![01-download](./docs/help-rufus-01-download.png)                                                                                                      |\n| 2. Open Rufus and fill out the fields as shown. Ensure you've backed up the data on the SD card before formatting. | ![02-selection](./docs/help-rufus-02-selection.png) ![03-alert](./docs/help-rufus-03-alert-hit-ok.png) ![04-loading](./docs/help-rufus-04-loading.png) |\n| 3. Eject the SD card from your computer                                                                            | ![05-eject](./docs/help-rufus-05-eject.png)                                                                                                            |\n\n## License\n\n[MIT](./LICENSE)\n\n## Contributing\n\nContributions are welcome! Whether it's bug fixes, feature additions, or documentation improvements, we appreciate your help in making this project better. For major changes or new features, please open an issue first to discuss what you would like to change.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzpg6%2Fesp32-sdcard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzpg6%2Fesp32-sdcard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzpg6%2Fesp32-sdcard/lists"}