0
\$\begingroup\$

I would like to create a small web server to enable or disable devices via ethernet connection, except that the network module and the SD reader did not seem to work if connected simultaneously. That is, if I remove the SD reader the Ethernet module starts to work perfectly.

Below I leave the current version of code used for the tests:

#include <SPI.h>
#include <Ethernet.h>
//#include <SD.h>
#include "SdFat.h"

SdFat SD;

#define SS_ETH 10
#define CS_microSD 9

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};

IPAddress ip(192, 168, 1, 177);

EthernetServer server(80);

void setup() {
  Serial.begin(9600);

  pinMode(SS_ETH, OUTPUT);
  digitalWrite(SS_ETH, HIGH);

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

  if (!SD.begin(CS_microSD)) {
    Serial.println("initialization failed!");
  } else {
    Serial.println("initialization done.");
  }

  // start the server
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // LOOP
}

output produced by the program via serial:

Initializing SD card...
initialization done.
server is at 255.255.255.255

If instead I remove the microSD from the reader and restart the circuit I get:

Initializing SD card...
initialization done.
server is at 0.0.0.0

Hardware:

Wiring diagram

  • pin 9 -> CS microSD
  • pin 10 -> SS Ethernet
  • pin 11 -> MOSI
  • pin 12 -> MISO
  • pin 13 -> SCK

schematic

simulate this circuit – Schematic created using CircuitLab

Update 1: Thanks to the suggestions of @Juraj I tried to disconnect the MISO pin of the SD reader and the IP assignment was successful. Furthermore the SD.h library has been replaced with SdFat.h ..

The card reader has an LVC125A level converter as shown in this image: https://e-radionica.com/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/d/s/dsc_1819.jpg

Also here is the LVC125A level converter datasheet: https://www.alldatasheet.com/datasheet-pdf/pdf/171748/TI/LVC125A.html

UPDATE 2: a hardware modification to the reader is required to solve the problem since the MISO pin remains permanently enabled. https://forum.arduino.cc/index.php?topic=360718.msg2942160#msg2942160

\$\endgroup\$
  • \$\begingroup\$ many SD card adapters do that. they have a logic level conversion on MISO and that disturbs the bus. but 0.0.0.0 is not a good output either. first make the ethernet work \$\endgroup\$ – Juraj Aug 14 '19 at 10:58
  • \$\begingroup\$ thanks for your comment Juraj! how could the noise produced by the SD card reader be reduced? \$\endgroup\$ – Pinguto Aug 14 '19 at 11:02
  • \$\begingroup\$ I am not an expert of this, but in my understanding the card doesn't drive the line while it is not selected, so the converter has the 5 V side HIGH \$\endgroup\$ – Juraj Aug 14 '19 at 11:17
  • \$\begingroup\$ I had already tried, but with no result .. however I did not know that SD readers disturbed the MISO communication line and right now I was looking at this discussion: forum.arduino.cc/index.php?topic=276274.0 \$\endgroup\$ – Pinguto Aug 14 '19 at 11:23
  • 1
    \$\begingroup\$ you can inspect the SD module traces to see if it has level conversion on MISO \$\endgroup\$ – Juraj Aug 16 '19 at 13:20
0
\$\begingroup\$

As already written in the question I opened the problem was solved by performing this change to the card reader: https://forum.arduino.cc/index.php?topic=360718.msg2942160#msg2942160

Micro SD readers equipped with LVC125A chips have the MISO output perpetually enabled and disrupting communication with other devices.

I thank one last time @Juraj for his support: without his advice I could never have solved my problem. Thank you!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.