Skip to content

Commit 6b24b99

Browse files
committed
feat(wokwi-microsd-card/sd-esp32): add test
1 parent 076de82 commit 6b24b99

File tree

6 files changed

+103
-0
lines changed

6 files changed

+103
-0
lines changed

.github/workflows/wokwi-test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
- name: dht22-stm32
2626
path: wokwi-dht22/dht22-stm32
2727
scenario: dht22.test.yaml
28+
- name: microsd-card-esp32
29+
path: wokwi-microsd-card/sd-esp32
30+
scenario: sd.test.yaml
2831
- name: slide-potentiometer-uno
2932
path: wokwi-slide-potentiometer/pot-uno
3033
scenario: slide-potentiometer.test.yaml
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"version": 1,
3+
"author": "Uri Shaked",
4+
"editor": "wokwi",
5+
"parts": [
6+
{
7+
"type": "wokwi-esp32-devkit-v1",
8+
"id": "esp",
9+
"top": 26.66,
10+
"left": -10.02,
11+
"rotate": 270,
12+
"attrs": {}
13+
},
14+
{
15+
"type": "wokwi-microsd-card",
16+
"id": "sd1",
17+
"top": -33.33,
18+
"left": 15.43,
19+
"rotate": 90,
20+
"attrs": {}
21+
}
22+
],
23+
"connections": [
24+
["esp:TX0", "$serialMonitor:RX", "", []],
25+
["esp:RX0", "$serialMonitor:TX", "", []],
26+
["sd1:SCK", "esp:D18", "green", ["v18", "h-31"]],
27+
["sd1:GND", "esp:GND.1", "black", ["v21", "h-48"]],
28+
["sd1:DO", "esp:D19", "green", ["v24", "h-42"]],
29+
["sd1:DI", "esp:D23", "green", ["v14", "h6"]],
30+
["sd1:CS", "esp:D5", "green", ["v7", "h21"]],
31+
["sd1:VCC", "esp:3V3", "red", ["v11", "h-89", "h79"]]
32+
]
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[env:esp32dev]
2+
platform = espressif32
3+
board = esp32dev
4+
framework = arduino
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 1
2+
name: 'MicroSD Card Test'
3+
author: 'Uri Shaked'
4+
5+
steps:
6+
- wait-serial: 'SD card initialized successfully'
7+
- wait-serial: 'File created successfully'
8+
- wait-serial: 'Data written successfully'
9+
- wait-serial: 'Data read successfully'
10+
- wait-serial: 'Test completed'
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include <SPI.h>
2+
#include <SD.h>
3+
4+
const int chipSelect = 5;
5+
File myFile;
6+
7+
void setup() {
8+
Serial.begin(115200);
9+
10+
Serial.print("Initializing SD card...");
11+
if (!SD.begin(chipSelect)) {
12+
Serial.println("initialization failed!");
13+
return;
14+
}
15+
Serial.println("SD card initialized successfully");
16+
17+
// Create a test file
18+
myFile = SD.open("/test.txt", FILE_WRITE);
19+
if (myFile) {
20+
Serial.println("File created successfully");
21+
22+
// Write some data
23+
myFile.println("Hello, Wokwi!");
24+
myFile.close();
25+
Serial.println("Data written successfully");
26+
} else {
27+
Serial.println("Error creating file");
28+
return;
29+
}
30+
31+
// Read the file
32+
myFile = SD.open("/test.txt");
33+
if (myFile) {
34+
Serial.println("Data read successfully");
35+
while (myFile.available()) {
36+
Serial.write(myFile.read());
37+
}
38+
myFile.close();
39+
} else {
40+
Serial.println("Error opening file");
41+
return;
42+
}
43+
44+
Serial.println("Test completed");
45+
}
46+
47+
void loop() {
48+
// Nothing to do here
49+
}
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[wokwi]
2+
version = 1
3+
firmware = '.pio/build/esp32dev/firmware.bin'
4+
elf = '.pio/build/esp32dev/firmware.elf'

0 commit comments

Comments
 (0)