Problème Arduino Mega+Shield Ethernet

Débutant en informatique, je n'arrive pas initialiser la communication avec la carte micro SD insérée dans mon shield ethernet malgré que la carte SD soit bien formatée en FAT32 (Je possède une Arduino Mega et un Shield Ethernet HanRun HR911105A).
Pourriez-vous m'aider ?

Bonjour

"Shield Ethernet HanRun HR911105A" ?
disons que l'un des composants du 'shield' , l'embase Ethernet porte la référence HanRun HR911105A .... comme de nombreuses cartes Ethernet diverses.....
photo HR.png

Il faut être plus précis concernant le shield utilisé : lien vers un site marchand ou photo
+Copier ici le code utilsié pour communiquer avec ce shield (pour la publication du code se référer auxx messages épinglés en tête de forum)

photo HR.png

baptdes:
Débutant en informatique, je n'arrive pas initialiser la communication avec la carte micro SD insérée dans mon shield ethernet malgré que la carte SD soit bien formatée en FAT32 (Je possède une Arduino Mega et un Shield Ethernet HanRun HR911105A).
Pourriez-vous m'aider ?

bonjour
est ce que le cs pin du lecteur SD est bien affecté par le programme ?

Le shield utilisé est celui-ci : https://www.amazon.fr/gp/product/B01D0KELYM/ref=ppx_yo_dt_b_asin_title_o05_s00?ie=UTF8&psc=1
Et j'utilise le code en exemple SD card read/write :

#include <SPI.h>
#include <SD.h>

File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


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

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop() {
  // nothing happens after setup
}

Il faut d'abord initialiser le W5100, ensuite initialiser la carte SD, même si la partie W5100 n'est pas utilisée.
Donc : Ethernet.begin(mac, ip) avant tout.

Merci ça marche ! :slight_smile:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.