ETHERNET ET CARTE SD

Bonjour,
j'utilise le shield ethernet pour que l'arduino dans le rôle du serveur affiche un site depuis la carte sd

code arduino :

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
 
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0xF3, 0x9B }; //adresse mac de votre carte
byte ip[] = {192, 168, 0, 16}; //adresse IP
EthernetServer server(80);  // create a server at port 80
 
File webFile;

void setup()
{
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
    Serial.begin(9600);       // for debugging
    
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
}

void loop()
{
    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) {
                    // send a standard http response header
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println("Connection: close");
                    client.println();
                    // send web page
                    webFile = SD.open("confort.htm");        // open web page file
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    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)
}

code html :

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>confort</title>
     <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
  <header><h1 id="titre">
  Gérer le confort
  </h1></header>
  <div id ="menu">
  <table>
   <tr>
       <td name="tab1">acceuil</td>
       <td name="tab1">confort</td>
       <td name="tab1">sécurité</td>
   </tr>
</table>
  </div>
  
     <nav>
          <div id="champ1">
<p class="flotte">
 <img src="logo.png" alt="Nouveau !" />
</p>
<h2 id="titre2">
  L'éclairage
  </h2>
  <input type="checkbox" id="lampe_ext1" name = "boite" >
  <label for="boite"  id="texte_lampe_ext1" class="rouge"></label><img src="rien.jpg" alt ="ext1 " name="1" id ="image1">


   <input type="checkbox" id="lampe_ext2" name = "boite" >
  <label for="boite"  id="texte_lampe_ext2" class="rouge"></label><img src="rien.jpg" alt ="ext2 " name="1" id ="image2" >


<input type="checkbox" id="lampe_maison" name = "boite" >
  <label for="boite"  id="texte_lampe_maison" class="rouge"></label><img src="rien.jpg" alt ="maison " name="1" id ="image3" >


<input type="checkbox" id="lampe_studio" name = "boite" >
  <label for="boite"  id="texte_lampe_studio" class="rouge"></label><img src="rien.jpg" alt ="studio " name="1" id ="image4" >




</div> 







  <div id="champ2">

<p class="flotte">
 <img src="logo2.png" alt="Nouveau !" />
</p>

<h2 id="titre3">
  Le chauffage
  </h2>
  <input type="checkbox" id="chauffage_salon" name = "boite" >
  <label for="boite"  id="texte_chauffage_salon" class="rouge"></label><img src="rien.jpg" alt ="ext1 " name="1" id ="image5">


   <input type="checkbox" id="chauffage_chambre" name = "boite" >
  <label for="boite"  id="texte_chauffage_chambre" class="rouge"></label><img src="rien.jpg" alt ="ext2 " name="1" id ="image6" >


<input type="checkbox" id="chauffage_studio" name = "boite" >
  <label for="boite"  id="texte_chauffage_studio" class="rouge"></label><img src="rien.jpg" alt ="maison " name="1" id ="image7" >



</div> 





        </nav>
        
        <section>
         <div id="parent">

          <img src="maison.png"  class ="superpose" alt ="maison " name = "2" id ="maison">
              <img src="maison1.png"  class ="superpose" alt ="lampe1 " name = "2" id ="maison1">
               <img src="maison2.png"  class ="superpose" alt ="lampe2 " name = "2" id ="maison2">
               <img src="maison3.png"  class ="superpose" alt ="lampe3 " name = "2" id ="maison3">
               <img src="maison4.png"  class ="superpose" alt ="lampe4 " name = "2" id ="maison4">
               <img src="maison5.png"  class ="superpose" alt ="radiateur1 " name = "2" id ="maison5">
               <img src="maison6.png"  class ="superpose" alt ="radiateur2 " name = "2" id ="maison6">
               <img src="maison7.png"  class ="superpose" alt ="radiateur3 " name = "2" id ="maison7">
              
</div >

        </section>        
        
   

    
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
   <script src="domotique.js"></script>
     
  </body>
</html>

code css

body
{
    background-color: rgb(92,138,163);    
}

h1{
  text-align: center;
}
#titre
{font-size: 18 px;
color: black;}

#titre2
{font-size: 16 px;
color:  rgb(167,69,25);}

#titre3
{font-size: 16 px;
color:  rgb(11,56,116);}

#menu
{margin-left: auto;
    margin-right: auto;
    width: 10em;
    }
    
  td
{  border-width:1px;
 border-style:solid; 
 border-color:black;
    }
img[name="1"]{
 width: 20px;
	height: auto;
}

img[name="2"]{
 width: auto;
    height: 500px;
}

#champ1
{
    
    border: 1px solid black;
   
}

#champ2
{
    
    border: 1px solid black;
   
}


nav
{
    display: inline-block;
    width: 30%;
    border: 1px solid black;
    vertical-align: top;
}   
section
{
    display: inline-block;    
    border: 1px solid blue;
    vertical-align: top;
    height: 500px;
}


.rouge { color: red; }
      .vert { color: green; }
.bleu { color: blue; }
#parent {
   position: relative;
}
img.superpose {
   position: absolute;
   top: 0px;
   left: 0px;
}
#maison {
   z-index: 100;
}
#maison1 {
   z-index: 99;
}
#maison2 {
   z-index: 98;
}
#maison3 {
   z-index: 97;
}
#maison4 {
   z-index: 96;
}
#maison5 {
   z-index: 95;
}
#maison6 {
   z-index: 94;
}
#maison7 {
   z-index: 93;
}
.flotte {
float:left;
}

code jquery

$(function(){
   
 $('#lampe_ext1').change( function() {
                if( $('#lampe_ext1').is(':checked') ) 
{$('#texte_lampe_ext1').removeClass('rouge').addClass('vert');
 $('#texte_lampe_ext1').html('extérieur allumé.');
 $('#image1').attr('src','allume.png');
  $('#maison').attr('src','maison.png');

   $('#maison1').css('z-index' , '101');
 }
  else
  { $('#texte_lampe_ext1').html('extérieur eteint.');
  
  $('#texte_lampe_ext1').removeClass('vert').addClass('rouge');
   $('#image1').attr('src','rteint.png');
   $('#maison').attr('src','maison.png');
$('#maison1').css('z-index' , '99');

}
});

sur mon navigateur depuis mon pc ça marche mais depuis l'arduino les images n'apparaissent pas 
problème de capacité de l'arduino?

votre image

mais quelle est la question ? (votre code Arduino ne répond qu'à une seule requête HTPP toujours de la même façon avec confort.htm quelle que soit la requête ? c'est louche)

L'image correspond à la page attendue, celle que je joins ici correspond à celle renvoyée par l'arduino
d'où le problème

l'autre image (apprenez à les poster en lisant les règles du forum et sujets connexes)

votre souci comme je le dis plus haut c'est que quand le navigateur reçoit la page principale en HTML il doit demander toutes les autres resources au serveur... et vous ne servez jamais ces autres resources (logo.png, logo2.png, maison.png, ...) --> faut détecter la requête reçue sur l'Arduino et envoyer la resource demandée pas juste la page générique standard HTML à chaque fois. (imprimez ce que le GET vous demande vous verrez sans doute passer pleins de requêtes)

ok, merci je vais travailler en ce sens

Après quelques recherche, je me rends effectivement compte qu'il est nécessaire, d'analyser la requete get. Afin de simplifier le travail, j'impose que chaque page html soit enregistrée sous h01.htm, h02.htm...De la même façon les images sont enregistrées sous I01.png, I02.png. dANS LE PROGRAMME on sauvegarde la premiere ligne du client avec sa requète get dans un buffer, puis :
on analyse le 9eme caractère afin de connaitre le type : si h alors html, si p alors png etc..
puis on examine le 7eme caractère afin de connaitre le numéro de page ou d'image (limité à 10)
:

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#define REQ_BUF_SZ   20// buffer pouvant accueillir la requete get de taille 20 car le nom a 3 caractere max et l'extension aussi

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0xF3, 0x9B }; //adresse mac
IPAddress ip(192, 168, 0, 16);//adresse ip locale
// IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80
File webFile;
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer


void setup()
{
    // disable Ethernet chip
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);
    
    Serial.begin(9600);       // for debugging
    
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
    
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
}

void loop()
{
    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
                // buffer first part of HTTP request in HTTP_req array (string)
                // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
                if (req_index < (REQ_BUF_SZ - 1)) {
                    HTTP_req[req_index] = c;// save HTTP request character
                    req_index++;
                    
                }
                // print HTTP request character to serial monitor
                Serial.print(c);
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
 Serial.println(HTTP_req[7]);
                     Serial.println(HTTP_req[9]);
                
                if (c == '\n' && currentLineIsBlank) {
                    // open requested web page file
                    if (StrContains(HTTP_req, "GET / ")
                                 || (HTTP_req[9] == 'h')) {
                        client.println("HTTP/1.1 200 OK");
                        client.println("Content-Type: text/html");
                        client.println("Connnection: close");
                        client.println();

                        switch (HTTP_req[7]) {
                           case '1':
                           webFile = SD.open("h01.htm");
                          break;
                          case 'T':
                           webFile = SD.open("h01.htm");
                          break;
                            case '2':
                           webFile = SD.open("h02.htm");
                          break;
                             
                    }
                                       }
                                       
                    else if (HTTP_req[9] == 'p') {
                            switch (HTTP_req[7]) {
                           case '1':
                           webFile = SD.open("I01.png");
                                             if (webFile) {
                            client.println("HTTP/1.1 200 OK");
                            client.println();}
                          break;
                         
                            case '2':
                           webFile = SD.open("I02.png");
                                             if (webFile) {
                            client.println("HTTP/1.1 200 OK");
                            client.println();}
                          break;
                        
                    }}
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    // reset buffer index and all buffer elements to 0
                    req_index = 0;
                    StrClear(HTTP_req, REQ_BUF_SZ);
                    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)
}




// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
    for (int i = 0; i < length; i++) {
        str[i] = 0;
    }
}

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
    char found = 0;
    char index = 0;
    char len;

    len = strlen(str);
    
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return 1;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;
}

Cependant cela ne marche pas et les caracteres renvoyés ne correspondent pas à mes attentes

Imprimez sur Serial l’ensemble des requêtes que vous recevez (tout le texte de la requête) ça vous permettra de voir ce que le navigateur attend et si votre analyseur est correct

Merci pour ton conseil. J'ai donc placé un serialprint au début de ma boucle et dans le moniteur je vois que l'élément identifier est bien la lettre p mais pour autant cela n'active pas la condition qui lui est liée et donc l'image ne s'affiche pas. Je ne comprends pas pourquoi :

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#define REQ_BUF_SZ   20// buffer pouvant accueillir la requete get de taille 20 car le nom a 3 caractere max et l'extension aussi

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0xF3, 0x9B }; //adresse mac
IPAddress ip(192, 168, 0, 16);//adresse ip locale
// IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80
File webFile;
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer


void setup()
{
    // disable Ethernet chip
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);
    
    Serial.begin(9600);       // for debugging
    
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
    
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
}

void loop()
{
    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
                // buffer first part of HTTP request in HTTP_req array (string)
                // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
                if (req_index < (REQ_BUF_SZ - 1)) {
                    HTTP_req[req_index] = c;// save HTTP request character
                    req_index++;
                    
                }
                // print HTTP request character to serial monitor
                Serial.print(c);
                // last line of client request is blank and ends with \n
                // respond to client only after last line received

                
                if (c == '\n' && currentLineIsBlank) {
                  Serial.println(HTTP_req[9]);
                    // open requested web page file
                    if (StrContains(HTTP_req, "GET / ")
                                 || (HTTP_req[9] == 'h')) {
                        client.println("HTTP/1.1 200 OK");
                        client.println("Content-Type: text/html");
                        client.println("Connnection: close");
                        client.println();

                        switch (HTTP_req[7]) {
                           case '1':
                           webFile = SD.open("h01.htm");
                          break;
                          case 'T':
                           webFile = SD.open("h01.htm");
                          break;
                            case '2':
                           webFile = SD.open("h02.htm");
                          break;
                             
                    }
                                       }
                                       
                    else if (image(HTTP_req[9]) ) {
                           
                           webFile = SD.open("I01.png");
                                             if (webFile) {
                            client.println("HTTP/1.1 200 OK");
                            client.println();}
                      }
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    // reset buffer index and all buffer elements to 0
                    req_index = 0;
                    StrClear(HTTP_req, REQ_BUF_SZ);
                    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)
}




// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
    for (int i = 0; i < length; i++) {
        str[i] = 0;
    }
}

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
    char found = 0;
    char index = 0;
    char len;

    len = strlen(str);
    
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return 1;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;
}

char image(char *str)
{
       
         if (str[9] == 'p') {
            
                return 1;
            }
      else {

    return 0;}
}

A mon avis :

client->println(F("HTTP/1.1 200 OK\nContent-Type: image/png\nConnection: close"));
Et ceci aussi je pense :
Content-length:

Merci de ton aide, je vais essayé de rajouter ce code derrière l'envoi de l'image. Cependant je pense que le problème est plus localisé sur le traitement des lettres de la requête car, par exemple ce code fontionne :

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#define REQ_BUF_SZ   20// buffer pouvant accueillir la requete get de taille 20 car le nom a 3 caractere max et l'extension aussi

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0xF3, 0x9B }; //adresse mac
IPAddress ip(192, 168, 0, 16);//adresse ip locale
// IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80
File webFile;
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer


void setup()
{
    // disable Ethernet chip
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);
    
    Serial.begin(9600);       // for debugging
    
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
    
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
}

void loop()
{
    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
                // buffer first part of HTTP request in HTTP_req array (string)
                // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
                if (req_index < (REQ_BUF_SZ - 1)) {
                    HTTP_req[req_index] = c;// save HTTP request character
                    req_index++;
                }
                // print HTTP request character to serial monitor
                Serial.print(c);
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                    // open requested web page file
                    if (StrContains(HTTP_req, "GET / ")
                                 || StrContains(HTTP_req, "GET /h01.htm")) {
                        client.println("HTTP/1.1 200 OK");
                        client.println("Content-Type: text/html");
                        client.println("Connnection: close");
                        client.println();
                        webFile = SD.open("ho1.htm");        // open web page file
                    }
                    else if (StrContains(HTTP_req, "GET /h02.htm")) {
                        client.println("HTTP/1.1 200 OK");
                        client.println("Content-Type: text/html");
                        client.println("Connnection: close");
                        client.println();
                        webFile = SD.open("ho2.htm");        // open web page file
                    }
                    else if (StrContains(HTTP_req, "GET /I01.jpg")) {
                        webFile = SD.open("I01.png");
                        if (webFile) {
                            client.println("HTTP/1.1 200 OK");
                            client.println();
                        }
                    }
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    // reset buffer index and all buffer elements to 0
                    req_index = 0;
                    StrClear(HTTP_req, REQ_BUF_SZ);
                    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)
}




// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
    for (int i = 0; i < length; i++) {
        str[i] = 0;
    }
}

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
    char found = 0;
    char index = 0;
    char len;

    len = strlen(str);
    
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return 1;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;
}

possible.

Il faut activer la console WEB.
Firefox : menu (en haut à droite) Développement WEB / Console WEB
Tu verras éventuellement apparaître "404 not found".

                    if (StrContains(HTTP_req, "GET / ")
// plus loin :
                    else if (image(HTTP_req[9]) ) {

Il serait étonnant que la requête pour l'image ne commence pas par /
else n'est probablement pas adapté.

si

Le navigateur demande adresse_ip**/**image.jpg

Bonjour,
Je n'ai pas eu le temps de tout lire car cela me semble un peu compliqué pour quelque chose qui est normalement simple : envoyer une requête GET à un serveur web pour déclencher des actions en fonction de la valeur des paramètres.
Voici un exemple que j'utilise pour une petite application chargée de déclencher un son et de faire clignoter une diode lorsque le serveur web reçoit la requête.

http://adresseIParduino:port?son=2&diode=1 (la requête envoyée avec 2 paramètres)

Côté serveur web dans le sketch .ino, il suffit de réaliser une fonction basée sur l'identification du caractère ? et du caractère & tant que le client est connecté.

//fonction décodage GET
String GET(EthernetClient cl) {
  int lecture = 0; // variable pour les étapes de décodage
  String donnee = ""; //chaine pour stocker la lecture des données
  
  while (cl.available())  { // tant qu'il a des infos à transmettre
    char c = cl.read(); // on lit le caractère
    
    if (lecture == 0 && c == '?') { //début de lecture des données donc d'un nom
      lecture = 1;
      donnee = "";
    }
    
    else if ((lecture == 1) && c == ' ') { //fin de lecture
      lecture = 2;
    }
    
    else if (lecture == 1) {//récupération des données de nom ou de valeur
      donnee += c;
    }
    
    delay(1); //delai de lecture
  }
 
 Serial.println(donnee); //pour vérifier dans le moniteur série
 

// traitement des actions en fonction de la valeur des paramètres 
 if(donnee.indexOf("son=1") >=0) {
     Serial.println("son=1 ok");
     son=1;
   }
 if(donnee.indexOf("son=2") >=0) {
     Serial.println("son=2 ok");
     son=2;
   }

 if(donnee.indexOf("diode=2") >=0) {
     Serial.println("diode=2 ok");
     diode=2;
   }

  
return donnee; // retour de la chaîne de réponse
}

Merci, pour les réponses apportées, en fait l'erreur était due à une accolade mal placée lors de l'écriture de la condition portée par le caractere 9 stocké dans le buffer. Le programme fonctionne mais le site hébergé doit être très léger peu d'images sinon tout ne charge pas

Bon j'essaie maintenant un combo : piloter deux del depuis un site chargé sur la carte sd
Je suis parti de ce code qui fonctionne à merveille :

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#include <Servo.h> 
int led = 8;

int pos = 0; 

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0xF3, 0x9B }; //adresse mac
IPAddress ip(192, 168, 0, 16);//adresse ip locale

EthernetServer server(80);  // create a server at port 80                           //server port     
String readString;

void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  pinMode(led, OUTPUT);
    pinMode(7, OUTPUT);
      pinMode(6, OUTPUT);

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
  digitalWrite(led, HIGH);
  delay(1000);
  digitalWrite(led, LOW);
  delay(1000);
   digitalWrite(7, HIGH);
  delay(1000);
  digitalWrite(7, LOW);
  delay(1000);
   digitalWrite(6, HIGH);
  delay(1000);
  digitalWrite(6, LOW);
  delay(1000);
}


void loop() {
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {   
      if (client.available()) {
        char c = client.read();
     
        //read char by char HTTP request
        if (readString.length() < 100) {
          //store characters to string
          readString += c;
          //Serial.print(c);
         }

         //if HTTP request has ended
         if (c == '\n') {          
           Serial.println(readString); //print to serial monitor for debuging
     
           client.println("HTTP/1.1 200 OK"); //send new page
           client.println("Content-Type: text/html");
           client.println();     
           client.println("<HTML>");
           client.println("<HEAD>");
           client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
           client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
           client.println("<link rel='stylesheet' type='text/css' href='https://randomnerdtutorials.com/ethernetcss.css' />");
           client.println("<TITLE>Random Nerd Tutorials Project</TITLE>");
           client.println("</HEAD>");
           client.println("<BODY>");
           client.println("<H1>Random Nerd Tutorials Project</H1>");
           client.println("<hr />");
           client.println("
");  
           client.println("<H2>Arduino with Ethernet Shield</H2>");
           client.println("
");  
           client.println("<a href=\"/?l1a\"\">Allumer salon</a>");
           client.println("<a href=\"/?l1b\"\">Eteindre salon</a>
");   
           client.println("
");     
           client.println("
"); 
           client.println("<a href=\"/?l2a\"\">Allumer studio</a>");
           client.println("<a href=\"/?l2b\"\">Eteindre studiot</a>
"); 
           client.println("<p></p>");  
           client.println("
"); 
           client.println("</BODY>");
           client.println("</HTML>");
     
           delay(1);
           //stopping client
           client.stop();
           //controls the Arduino if you press the buttons
           if (readString.indexOf("?l1a") >-1){
               digitalWrite(led, HIGH);
           }
           if (readString.indexOf("?l1b") >-1){
               digitalWrite(led, LOW);
           }
           if (readString.indexOf("?l2a") >-1){
                digitalWrite(6, HIGH);
           }
           if (readString.indexOf("?l2b") >-1){
                digitalWrite(6, LOW);
           }
            //clearing string for next read
            readString="";  
           
         }
       }
    }
}
}

et je l'ai scindé en
html :

<HTML>
  <HEAD>
         <meta name='apple-mobile-web-app-capable' content='yes' />
          <meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />
      <link rel='stylesheet' type='text/css' href='https://randomnerdtutorials.com/ethernetcss.css' />
          <TITLE>Random Nerd Tutorials Project</TITLE>
        </HEAD>
          <BODY>
           <H1>Random Nerd Tutorials Project</H1>
        <hr />
          
 
         <H2>Arduino with Ethernet Shield</H2>
         
 
          <a href=\"/?l1a\"\">Turn On LED</a>
           <a href=\"/?l1b\"\">Turn Off LED</a>
   
           
    
          

           <a href=\"/?l2a\"\">allumer salon</a>
          <a href=\"/?l2b\"\">eteindre salon</a>
 
          <p>Created by Rui Santos. Visit https://randomnerdtutorials.com for more projects!</p>
           

           </BODY>
           </HTML>

sur la carte sd

et arduino :

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
int led = 8;
// size of buffer used to capture HTTP requests
#define REQ_BUF_SZ   20

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0xF3, 0x9B }; //adresse mac
IPAddress ip(192, 168, 0, 16);//adresse ip locale
// IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80
File webFile;
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer
String readString;



void setup()
{
    // disable Ethernet chip
      pinMode(led, OUTPUT);
    pinMode(7, OUTPUT);
      pinMode(6, OUTPUT);
    
    Serial.begin(9600);       // for debugging
    
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("h01.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
    
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
 digitalWrite(led, HIGH);
  delay(1000);
  digitalWrite(led, LOW);
  delay(1000);
   digitalWrite(7, HIGH);
  delay(1000);
  digitalWrite(7, LOW);
  delay(1000);
   digitalWrite(6, HIGH);
  delay(1000);
  digitalWrite(6, LOW);
  delay(1000);}

void loop()
{
    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
                // buffer first part of HTTP request in HTTP_req array (string)
                // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
                if (req_index < (REQ_BUF_SZ - 1)) {
                    HTTP_req[req_index] = c;   
                    readString += c;// save HTTP request character
                    req_index++;
                }
                // print HTTP request character to serial monitor
                Serial.print(c);
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                
                    // open requested web page file
                    if (StrContains(HTTP_req, "GET / ")
                                 || StrContains(HTTP_req, "GET /h01.htm")) {
                        client.println("HTTP/1.1 200 OK");
                        client.println("Content-Type: text/html");
                        client.println("Connnection: close");
                        client.println();
                        webFile = SD.open("h01.htm");   
                        
                        
                        
                        
                        // open web page file
                    }
                    
                    else if ((HTTP_req[9])=='h') {
                      
                        client.println("HTTP/1.1 200 OK");
                        client.println("Content-Type: text/html");
                        client.println("Connnection: close");
                        client.println();
                         switch  (HTTP_req[7]){
                         case '2' :                        
                        webFile = SD.open("h02.htm"); 
                        break;
                        case '3' :                        
                        webFile = SD.open("h03.htm"); 
                        break;
                        
                    }}

                   

                    
                    else if (StrContains(HTTP_req, "GET /I01.png"))  {

                        webFile = SD.open("I01.png");
                        if (webFile) {
                            client.println("HTTP/1.1 200 OK");}}
                    
 else if (StrContains(HTTP_req, "GET /I02.png"))  {

                        webFile = SD.open("I02.png");
                        if (webFile) {
                            client.println("HTTP/1.1 200 OK");}}
                       
                           else if (StrContains(HTTP_req, "GET /I03.png"))  {

                        webFile = SD.open("I03.png");
                        if (webFile) {
                            client.println("HTTP/1.1 200 OK");}}
                          
                          
                   
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    // reset buffer index and all buffer elements to 0
                    req_index = 0;
                    StrClear(HTTP_req, REQ_BUF_SZ);
                    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(); 
          if (readString.indexOf("?l1a") >-1){
               digitalWrite(led, HIGH);
           }
           if (readString.indexOf("?l1b") >-1){
               digitalWrite(led, LOW);
           }
           if (readString.indexOf("?l2a") >-1){
                digitalWrite(6, HIGH);
           }
           if (readString.indexOf("?l2b") >-1){
                digitalWrite(6, LOW);
           }
            //clearing string for next read
            readString="";  
        
        
        
        // close the connection
    } // end if (client)
}

// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
    for (int i = 0; i < length; i++) {
        str[i] = 0;
    }
}

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
    char found = 0;
    char index = 0;
    char len;

    len = strlen(str);
    
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return 1;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;}

pb : cela ne fonctionne que si je clique sur les boutons toutes les secondes sinon un message d'erreur apparait : l la connexion a été réinitialisé...