This shield is designed for use with the Wemos/Lolin D1 mini and mini Pro development boards (see item HCWEMO0002). The shield provides a means of allowing a Wemos/Lolin D1 mini to directly communicate with most types of microSD card. it is also compatible with the standard Arduino SD card library. Supplied with two sets of pins headers for stacking onto a D1 Mini.
Features
Configurable CS pin, Default: D4 (GPIO0)
Pins
D1 mini GPIO Shield
D5 14 CLK
D6 12 MISO
D7 13 MOSI
D4 0 CS
Example Arduino Sketch:
- /* WeMos SD Card example - Created by HobbyComponents.com */
- #include <ESP8266WiFi.h>
- /* Include the standard SD card library */
- #include <SD.h>
- #define SD_CARD_CD_DIO D8 /* DIO pin used to control the modules CS pin */
- File SDFileData;
- /* Initialise serial and DIO */
- void setup()
- {
- Serial.begin(115200);
- Serial.println();
- /* Initialise the microSD card */
- if (!SD.begin(SD_CARD_CD_DIO))
- {
- /* If there was an error output this to the serial port and go no further */
- Serial.println("ERROR: SD card failed to initiliase");
- return;
- }else
- {
- Serial.println("SD Card OK");
- }
- /* Check if the text file already exists */
- while(SD.exists("test.txt"))
- {
- /* If so then delete it */
- Serial.println("test.txt already exists...DELETING");
- SD.remove("test.txt");
- }
- /* Create a new text file on the microSD card */
- Serial.println("Creating test.txt");
- SDFileData = SD.open("test.txt", FILE_WRITE);
- /* If the file was created ok then add come content */
- if (SDFileData)
- {
- SDFileData.println("It worked !!!");
- /* Close the file */
- SDFileData.close();
- Serial.println("done.");
- }else
- {
- Serial.println("Error writing to file !");
- }
- }
- /* Main program loop */
- void loop()
- {
- /* Nothing to do !*/
- }
Downloads
Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do not provide any guarantees or warranties as to their accuracy or fitness for purpose.