Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SD card not working when using Wifi AP. Working fine when connecting to an existing network. #10195

Open
1 task done
KobeOne2 opened this issue Aug 18, 2024 · 5 comments
Open
1 task done
Assignees
Labels
Area: Libraries Issue is related to Library support. Status: Awaiting triage Issue is waiting for triage

Comments

@KobeOne2
Copy link

Board

ESP32-S3

Device Description

ESP32-S3-WROOM-1

Hardware Configuration

#define SCK 18
#define MISO 19
#define MOSI 23
#define CS 5

Version

latest master (checkout manually)

IDE Name

Arduino IDE

Operating System

Windows 10

Flash frequency

80 MHz

PSRAM enabled

no

Upload speed

115200

Description

It appears that the SD card only works when not using an access point:

When an access point is created the sd card stops working.

WiFi.softAP("FHD", "123456789");

The SD card functions well as long as no AP is used. Do you have any idea what's going on here?

Sketch

#include <WiFi.h> //Built-in #include <ESP32WebServer.h> //https://github.com/Pedroalbuquerque/ESP32WebServer download and place in your Libraries folder #include <ESPmDNS.h>

#include "CSS.h" //Includes headers of the web and de style file #include <SD.h> #include <SPI.h>

#define SCK 18 //48 #define MISO 19 //36 #define MOSI 23 //35 #define CS 5 //37

ESP32WebServer server(80);

#define servername "FHD33" //Define the name to your server...

bool SD_present = false; //Controls if the SD card is present or not

/********* SETUP **********/

void setup(void) {
Serial.begin(115200);
WiFi.softAP("FHD", "123456789"); //Network and password for the access point genereted by ESP32 ////
 if (!MDNS.begin(servername)) {
Serial.println("Error setting up MDNS responder!"); ESP.restart(); }

Serial.print("Initializing SD card...");

if (!SD.begin(CS)) { 
Serial.println("Card failed or not present, no SD Card data logging possible..."); 
SD_present = false; 
} 
else { 
Serial.println(F("Card initialised... file access enabled...")); 
SD_present = true; 
}

server.begin();

Serial.println("HTTP server started"); }

/********* LOOP **********/

void loop(void) { 
server.handleClient(); //Listen for client connections
}

Debug Message

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13836
load:0x40080400,len:3608
entry 0x400805f0
Initializing SD card...Card failed or not present, no SD Card data logging possible...
HTTP server started

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@KobeOne2 KobeOne2 added the Status: Awaiting triage Issue is waiting for triage label Aug 18, 2024
@lbernstone
Copy link
Contributor

Please try this code. Pin 48 is a bad choice if using a dev board, as that is where the built-in LED is attached.

#include <WiFi.h>
#include <SD.h>

#define SCK  12 //default for S3
#define MISO 13
#define MOSI 11
#define CS   10

void setup(void) {
  Serial.begin(115200);
  WiFi.softAP("FHD", "123456789");
  Serial.print("Initializing SD card...");
  SPI.begin(SCK, MISO, MOSI, CS);
  if (!SD.begin(CS)) {
    Serial.println("SDCard failed");
  } else {
    Serial.println("SDCard initialised");
  }
}

@KobeOne2
Copy link
Author

KobeOne2 commented Aug 19, 2024

Thanks a lot!

It still does not work. When opening a file right after creating the AP the read fails. Before starting the AP it reads without issue. e.g.:

#include <WiFi.h>
#include <SD.h>

#define SCK  12
#define MISO 13
#define MOSI 11
#define CS   10

const char* ssid = "ESP32-Access-Point";
const char* password = "123456789";

void setup(void) {
  Serial.begin(115200);
  
  Serial.print("Initializing SD card...");
  SPI.begin(SCK, MISO, MOSI, CS);
  if (!SD.begin(CS)) {
    Serial.println("SDCard failed");
  } else {
    Serial.println("SDCard initialised");
  }
  
  File file2 = SD.open("/index.html", FILE_READ);
  if (file2) {
    Serial.println("Success");
    file2.close();
  }
  else{
    Serial.println("Fail");
  }

  WiFi.softAP(ssid, password);
  Serial.println("AP started");
  
  File file3 = SD.open("/index.html", FILE_READ);
  if (file3) {
    Serial.println("Success");
    file3.close();
  }
  else{
    Serial.println("Fail");
  }
}

This prints for me when running:

Initializing SD card...
SDCard initialised
Success
AP started
Fail

@lbernstone
Copy link
Contributor

lbernstone commented Aug 19, 2024

I'm unable to reproduce
Put a delay(100) in after you start the AP. Turn core debugging level to verbose and see if you get more info in the console.
It's possible this is a power issue, but that's a pretty strange result, if so.

@everslick
Copy link
Contributor

If I had to guess, I'd also say power supply.

@VojtechBartoska VojtechBartoska added the Area: Libraries Issue is related to Library support. label Aug 21, 2024
@VojtechBartoska
Copy link
Collaborator

@P-R-O-C-H-Y Please help with triage, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Libraries Issue is related to Library support. Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

5 participants