ENC28j60 module and SD-card module

Hello guys,

This is my first post on this forum, my name is Gabriel and i'm an electronics addict (and spear-fisherman addict but that is another story) :)).

The problem is like this: I have one arduino uno board, one SD Card module (from LCstudio the one without level adapter) and one ENC28j60 module.

I use CD4050 for SD module level shifting .

When i use them separately everything goes smooth and clear (i can read/write on sd card using any of the available library) and regarding the ETH module i've test it with the examples from EtherShield -so they work as they should (well there are some errors sometimes on the sd card but i guess that is because of the long cables that i use).

I've also tried to make them work together: reading an html file from SD card and send it over the network.... well here was no success. It doesn't really matter what method i used (read in buffer the print it out... send it char by char... anyway nothing i've tried worked).

I have some question for you, if you are kind enough to answer:

  1. Is there any order in particular that i should initialize the net module and sd card? (could be that both modules keep the MISO line up ... as far as i know, MISO line should be in a tristate if the device is not in use)
  2. Could be a problem to the fact that both output signals are from 3.3v IC (i saw that ENC28j60 is 5v tolerant but... could be a problem on SPI bus ? as far as i know it would be 3.6v as a minimum for a signal to be recognized as logical 1)
  3. Arduino is 3v tolerant on SPI bus?
  4. Can i use the logic from this tutorial Arduino Tutorials - Ethernet+SD and transpose it to my need regarding ENC28j60 IC?

Thank you in advance and i hope that you could help me regardin this problem.

Best regards,
Gabriel Tudoran

I'm sorry for being so rude, but can anyone put me on the right track... if there is one? It's almost a week since i do all kind of research and still not being able to make it work.

Thank you in advance.

Are you supplying power to the arduino externally or just from the usb? i was advised to do that when i was having hardware issues. hope that helps because thats all i have right now. cheers!

When in doubt, disable all SPI devices before starting any of them.

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

    // disable SD SPI
    pinMode(4, OUTPUT);
    digitalWrite(4,HIGH);

    // disable ENC28J60 SPI
    pinMode(10, OUTPUT);
    digitalWrite(10,HIGH);

    // now start the devices
    Serial.print(F("Starting SD..."));
    if(!SD.begin(4)) Serial.println(F("failed"));
    else Serial.println(F("ok"));

    // start the ethernet device
    Serial.print(F("Starting ENC28J60..."));
   // rest of your setup stuff

BTW, I use a W5100. More support for it.

Thank you for the answers ... but.... is it possible to enable both SPI slave (sd and network card)? That was one of the questions i had in mind, when one is enable the other one is disabled, of for this sync the SPI library have it own way?

Best regards

The libraries low level read and write functions control the SPI slave selects for each device once the devices are started correctly. Both should leave the slave select for that device HIGH (disabled) after each access call, so there will be no interference (bus collisions) on the SPI bus.

So as far as i understand the main logic behind SD+ENC28J60 is like this:

  • Put both devices on disable (CS high on both);
  • Init SD / init NET
  • enable SD - read from file in buffer
  • disable SD / enable eth
  • write to eth
  • disable eth

and so on until all content is send on.

Did i get it right?

Once they are started correctly, you don't have to do anything with the slave selects for either device. These are ok on my w5100/SD sketches.

  while(client.available())  {
     sdFile.write(client.read());
  }
// and
  while(sdFile.available()) {
    client.write(sdFile.read());
  }

Even though the second example works, I use a character array to increase the ethernet sending speed.

SurferTim thank you for your time. I will do some more tests and i will let you know. And again i will make a PCB that will host both modules and i will not use wires to connect them to arduino ... and also i will build a separate power supply of 5v and 3.3v hope it will help.

Best regards

Hey guys :slight_smile: problem solved: bought with 15USD an W5100 shield - worked from the first time XD

Thank you again for your help (i will try again with the ENC28j60 module when i will have a little more time)