sd and ethernet shield conflict

hello,
i'm using an ethernet shield and i'm thinking that there is a conflict between sd and ethernet
indeed with this code

void setup() {
  pinMode(A0,INPUT);
 pinMode(A1,INPUT);
  pinMode(A2,INPUT);  

   pinMode(5,OUTPUT);
  
  Serial.begin (9600); //initialisation de communication série

if (!SD.begin(4)){//teste la communication avec la carte(pin 4)

        Serial.println("Communication impossible");

        return; //stoppe le programme

    }

    else {

    Serial.println("Communication ok !");}
     


  
  Ethernet.begin (mac); //initialisatio de la communication Ethernet
  server.begin(); 
if (Ethernet.begin( mac) == 0)
{ Serial.println(" FAILED!");
}
else {
  Serial.println(" OK!");
Serial.print(" IP Address: ");


Serial.println( Ethernet.localIP()); 
Serial.print(" Default Gateway: ");
Serial.println( Ethernet.gatewayIP());
Serial.print(" Subnet Mask: ");
Serial.println( Ethernet.subnetMask());
Serial.print(" DNS Server: "); 
Serial.println( Ethernet.dnsServerIP());

}


if (!SD.begin(4)){//teste la communication avec la carte(pin 4)

        Serial.println("Communication impossible");

        return; //stoppe le programme

    }

    else {

    Serial.println("Communication ok !");}
     

}

i obtain
communication ok (with sd)
ethernet parameters ok
communication impossible

so it looks like that when ethernet is working i can not access to sd card.

Probably. Disable both before initializing either. This uses weak pullups.

void setup() {
   digitalWrite(4, HIGH);
   digitalWrite(10, HIGH);
// rest of your setup

thak you for helping,
but it's stll not working

Maybe you should post the code that "isn't working" and explain what happens that indicates that it isn't working.

here the code :

#include <SPI.h> //bibliothèqe pour SPI
#include <Ethernet.h> //bibliothèque pour Ethernet
#include <SD.h>


byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xF3, 0x9B}; // tableau pour l'adresse MAC de votre carte
EthernetServer server(80);


int dit;
int temperature;
int masse;
int effectif;

  

void setup() {
  pinMode(A0,INPUT);
 pinMode(A1,INPUT);
  pinMode(A2,INPUT);  

   pinMode(5,OUTPUT);
   
pinMode(4,OUTPUT);



  
  Serial.begin (9600); //initialisation de communication série

if (!SD.begin(4)){//teste la communication avec la carte(pin 4)

        Serial.println("Communication impossible");

        return; //stoppe le programme

    }

    else {

    Serial.println("Communication ok !");}
     


  
  Ethernet.begin (mac); //initialisatio de la communication Ethernet
  server.begin(); 
if (Ethernet.begin( mac) == 0)
{ Serial.println(" FAILED!");
}
else {
  Serial.println(" OK!");
Serial.print(" IP Address: ");


Serial.println( Ethernet.localIP()); 
Serial.print(" Default Gateway: ");
Serial.println( Ethernet.gatewayIP());
Serial.print(" Subnet Mask: ");
Serial.println( Ethernet.subnetMask());
Serial.print(" DNS Server: "); 
Serial.println( Ethernet.dnsServerIP());

} 


if (!SD.begin(4)){//teste la communication avec la carte(pin 4)

        Serial.println("Communication impossible");

        return; //stoppe le programme

    }

    else {

    Serial.println("Communication ok !");}
   

}



void loop() {
  

temperature = analogRead (A0);
masse = analogRead (A1);
effectif = analogRead (A2);
 
  
EthernetClient client = server.available();  // try to get client

    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client



                  

                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {

true;
        
     


                  
                    // send a standard http response header
                    client.println(F("HTTP/1.1 200 OK"));
                    client.println(F("Content-Type: text/html"));
                    client.println(F("Connection: close"));
                    client.println();
                    // send web page
                    client.println(F("<!DOCTYPE html>"));
                    client.println(F("<html>"));
                    client.println("<head>");
                    client.println("<META HTTP-EQUIV=""Refresh"" CONTENT=""5"">");
                    client.println("<title>Arduino Web Page</title>");
                    client.println("</META>");
                    client.println("</head>");
                    client.println("<body>");
client.println(F(" <div style=""text-align: center; font-weight: bold; color: rgb(255, 102, 0);""><big><big><span style=""font-family: Javanese Text;"">Ma ruche connecte</span>
</big></big></div>"));
client.println(F("<span style=""font-family: Courier New,Courier,monospace;""></span>"));
client.println(F("<table style=""text-align: left; width: 1251px; height: 119px;"" border=""1""cellpadding=""2"" cellspacing=""2"">"));          
client.println(F("<tbody>"));
client.println(F("<tr>"));
client.print(F("<td style=""width: 18%;""><span style=""font-weight: bold; font-family: Marlett;""> temperature:  "));
client.print(temperature);
client.println(F("</span></td>"));

client.println(F("<td style=""width: 40%;"" colspan=""1"" rowspan=""3""><img src='ruche.jpg'></td>"));


client.println(F(" <td colspan=""1"" rowspan=""3"" align=""undefined"" valign=""undefined"">video</td>"));
client.println("</tr>");
client.println("<tr>");
client.print(F("<td align=""undefined"" valign=""undefined""><span style=""font-weight: bold; font-family: Marlett;"">Masse:  "));
client.print(masse);
client.println(F("</span></td>"));
  client.println(F(" </tr>"));
    client.println(F(" <tr>"));
      client.print(F("<td align=""undefined"" valign=""undefined""><span style=""font-weight: bold; font-family: Marlett;"">Effectif:  "));
client.print(effectif);
client.println(F("</span></td>"));
      
      client.println(F(" </tr>"));
     client.println(F(" </tbody>"));
    client.println(F("</table>"));
    client.println(F("
"));
      
   
   
  
   
 



                

                    
                    break;
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client)

  
}

in the setup at the begining the sd card is detected and i receive the message communication ok
after all the web parameters appear
and at the end of the setup code i receive the message communication impossible meaning that sd card is no more detected
i have tried many thing for exemple manualy write the cs pin at low but nothing works
i’m using arduino uno with this shield :Shield Ethernet EF02029 Elecfreaks - Articles retires | GO TRONIC