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:
- Arduino Nano
- W5100 ethernet module ( https://www.ebay.it/itm/SHIELD-MINI-W5100-modulo-ETHERNET-per-ARDUINO-ART-CV05/262454631406?hash=item3d1b83dbee:g:ltYAAOSwHsRYE0KC )
- microSD reader ( https://www.ebay.it/itm/Lettore-micro-SD-card-reader-writer-pic-arduino-raspberry-shield-ART-CL06/261625448910?hash=item3cea1789ce:g:tF0AAOSwAYtWOclu )
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
-
1\$\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– Juraj2019年08月14日 10:58:09 +00:00Commented Aug 14, 2019 at 10:58
-
1\$\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– Juraj2019年08月14日 11:17:28 +00:00Commented Aug 14, 2019 at 11:17
-
1\$\begingroup\$ so you will try SdFat library? Bill Greiman mentions the level shifters problem in this comment forum.arduino.cc/index.php?topic=276274.msg2016819#msg2016819 \$\endgroup\$Juraj– Juraj2019年08月14日 13:26:19 +00:00Commented Aug 14, 2019 at 13:26
-
1\$\begingroup\$ Can you post the schematic of both modules and the wiring you have done? As it currently stands from your description, you are missing ground connection. \$\endgroup\$Dmitry Grigoryev– Dmitry Grigoryev2019年08月14日 13:31:01 +00:00Commented Aug 14, 2019 at 13:31
-
2\$\begingroup\$ you can inspect the SD module traces to see if it has level conversion on MISO \$\endgroup\$Juraj– Juraj2019年08月16日 13:20:05 +00:00Commented Aug 16, 2019 at 13:20
1 Answer 1
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!