communication entre arduino ethernet

Bonjour,

j'ai un projet domotique avec 2 cartes arduino minimum. Les cartes seront branché sur mon réseau éthernet. Existe t-il un programme pour faire communiquer les cartes entre elles , ainsi que par PC ?

merci

D'après ce que je sais pour communiquer entre deux cartes il faut relier les deux sur les bornes tx-rx

bonjour,
oui la liaison est faisable, non pas par rx tx puisque via ethernet.
tu connecte le tout sur un routeur et roule poulette.

Par requête HTML peu être non ? En indiquant ton IP, tu peux envoyer une requête qui est traduit par l'autre arduino et pourront ainsi communiquer ensemble.

Look that :

//PIN 13,12,11,10, 4 utilisé par ethernet shield

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  // ICI met une adresse mac qui doit etre unique sur ton réseau local
IPAddress ip(10,10,129,52);     // remplace ceci par ton adresse IP local de ton arduino
EthernetServer server(80);
EthernetClient client;

//capteur
 
 int relais = 7;

void setup() {


  pinMode(relais,OUTPUT);

  Ethernet.begin(mac, ip);
  server.begin();
  Serial.begin(9600);
  
}


void loop()
{  client = server.available();

  if (client)ethernet();
}

void ethernet()
{
  if (client) { 
    boolean currentLineIsBlank = true;
    String buffer="";
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        buffer+=c;
        Serial.write(c);
        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");  // the connection will be closed after completion of the response
	  //client.println("Refresh: 60");  // refresh the page automatically every 60 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          
          client.println("<form action=\"http://10.10.129.52/\">");   // Attention ici met l'adresse ip de l'arduino avec lequel tu veux communiquer
// n'oublie pas que si tu veux communiquer hors local tu dois ouvrir un port de ta box et le renvoyer vers l'ip de ton arduino
          
          if(digitalRead(relais)==LOW){
           client.println("<button type=\"submit\" name=\"AllumerAlarme\" value=\"1\">Allumer Alarme</button>");  
        }
         else if(digitalRead(relais)==HIGH) client.println("<button type=\"submit\" name=\"AllumerAlarme\" value=\"0\">Eteindre Alarme</button>");

          client.println("</form>");
          client.println("</html>");
          break;
        }
        
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
         if (buffer.indexOf("AllumerAlarme=1")>0) digitalWrite(relais,HIGH);
        
         if (buffer.indexOf("AllumerAlarme=0")>0) digitalWrite(relais,LOW);
         
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    client.stop();
  }
}

Les commentaires sont dans le code quand je recois une certaine requete, mon arduino fait qqch de spécifique