Using SD file access and WiFi in the same sketch on Wio Terminal

I am trying to create an AP which has a http server and stores data on the SD card. I am having an issue where i can’t get both to work in the same sketch. In the below sketch the SD card works if i comment out the WiFi includes. Any Suggestions ? ( APinfo.html is an arbitrary file on the SD card. Card is 8 GB formatted with FAT32.

Output when code fails:

Initializing SD card…initialization done.

//--------Start of Sketch -------

#include <Seeed_FS.h>
#include "SD/Seeed_SD.h"
#include <AtWiFi.h>  // Remove these two lines and File System works
#include <WiFiClient.h> //

//#include <SPI.h>

File myFile; //Intialise the file Class and named it myFile

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial) {
  }
  Serial.print("Initializing SD card...");
  if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI)) {
    Serial.println("SD initialization failed!");
    while (1);
  }
    Serial.println("initialization done.");
    Serial.println();

myFile = SD.open("APinfo.html", FILE_READ); //Read Mode
  if (myFile) 
  {
    Serial.println("APinfo.html:");
 
    // read from the file until there's nothing else in it:
    while (myFile.available()) 
    {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } 
  else 
    {
    // if the file didn't open, print an error:
    Serial.println("Error APinfo.html");
    }

  
}

void loop() {
  // put your main code here, to run repeatedly:

}

Hi @blanee

It seems to be working okay on my end? Did I miss something sth

Added connection to a Wifi to double check here:

Can you also provide a screenshot of Serial monitor

It seems to hang in the SD_open call. Enclosed is the screenshot of the Serial Monitor.
If it works for you, the only thing i can think of is library versions.
I am using WiFi Release 1.2.7
SD 1.2.4 , but i also tried the version that was modified 2 days ago for a 4K sector size, but it did not make a difference.
All other libraries were loaded last week. Without the SD card libraries, the WiFi works fine for me.
Thanks for your help, Blane

Hi @blanee

Just had a look, seems like there is bug in the latest commit. We will look into this FS running with Wi-Fi. For now, you can roll back the previous commit and they work together.

image

Thanks, I reverted to Seeed_Arduino_FS-1.0.0 for the file system and it seems to be working now. It is also working with the LCD library as well.

Thanks, blane

2 Likes

Hi @ansonhe97
I updated the WiFi library, SD card library, etc. to the latest version.
It is not possible to use SD and WiFi at the same time. Wio Terminal freezes.
please check.

I used the example of the first post by @blanee
I want to save a file while connecting to WiFi.

PS: Of course, I already had this problem that I had to downgrade to Seeed_Arduino_FS-1.0.0.

Hi @blizzard

Are you using the newRPC wifi firmware?

Seems okay with the latest software on my end

1 Like

@ansonhe97
Yes, I updated to the latest version (newRPC wifi). Also I updated all the libraries.
Please test again if possible.

Can you provide your code again, let me test your environment :smiley: