Wifi shield; problems with SD-card

Hi!

I can't get my wifi shield work when I have SD-card in its place.

Here is an example code I've been running.

#include <SPI.h>
#include <SD.h>
#include <WiFi.h>
int x=0;
void setup() {
  Serial.begin(9600);
  // disable wifi while starting SD
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);
   
  Serial.print("Starting SD...");
  if (!SD.begin(4)) {
    Serial.println("failed");
  }
  else Serial.println("ok");

  if(WiFi.status() == WL_NO_SHIELD) {
   Serial.println(F("WiFi shield not present"));
   // don't continue:
   while(true);
  }
  

  Serial.println("initialization done.");
}
void loop()
{
  Serial.println(x);
  x=(x+1)*10;
  delay(3000);
}

When I have SD-card in its slot I get:
"Starting SD...failed
WiFi shield not present"
on serial monitor.

So in this scenario arduino won't recognize either the SD or the wifi.

When I remove SD-card from wifi shield, the code runs through the setup and goes to loop. So WiFi.status() returns something else now. But !SD.begin(4) is still true.

I wonder if anyone has any suggestions? Am I missing something or using the SS-pins somehow wrong?

The SD card shares the SPI pins with the WiFi chip. Perhaps your SD card is defective and is interfering with the use of the WiFi chip. Does the SD card work on another device?

Stick with your first post, more detail, so you don't have to restate what is going on I did my best to help you, but I don't have access to the equipment you are using, therefor I can not debug it. But I did help you word it in such a way that someone else should be able to figure out what is going on, and help you figure it out.

Read this Suggestion 13 says

Don't cross-post! We know you are anxious to get an answer to your problem, but re-posting the same question to multiple parts of the forum causes duplicate effort, and divides the focus on your problem. You'll get a better answer if everyone can discuss it in one place. Cross-posting is very annoying; the moderators will delete your extra posts, and you will get a warning. Save all the hassle, and just post the question once. It will be noticed.