Ethernet and SPI with Ethernet board

I have searched the forum and internet, and hope not the this is a stupid question.

Hardware: Ethernet board

Software: Ethernet, SD-card, SPI for sensor.

Setup: I would like to setup my Arduino Ethernet board with both Ethernet communication, storage of data on the SD card and measurements from a sensor connected to the SPI line.

Question: Is it possible to communicate both with the Ethernet connection, the SD card and a sensor connected to the SPI line (not at the same time) ?

Background: I have read on the webpage http://arduino.cc/en/Main/ArduinoBoardEthernet that "NB: Pins 10, 11, 12 and 13 are reserved for interfacing with the Ethernet module and should not be used otherwise.". My question is whether this is correct or not, the SCK, MISO, MOSI and ETHCS is available pins on the Ethernet board.

Are there an other solution for SPI communication if the Ethernet don't support it ?

Hopefully someone could help me answering this question !

Question: Is it possible to communicate both with the Ethernet connection, the SD card and a sensor connected to the SPI line (not at the same time) ?

Yes, and all at the same time. Each device needs a separate slave select pin (Ethernet = 10; SD = 4). The Ethernet and SD classes manage enabling the correct slave select pin. You'll need to do the same for your device/slave select pin.

My question is whether this is correct or not,

It is and it isn't. It is true that they should not be used for LEDs or switches. They can be used for SPI with other devices.

Great - this will be a good day :slight_smile:

Thanks a lot for your precise and fast answer.

Check the SPI mode on the sensor. If it is mode 0, it will work out of the box. If not, you will need to modify the SPI mode before and after each transfer to the sensor. This post covers how to do that.

I just foumd this article: RFM12B and Arduino Ethernet with WizNet5100 chip – Martin's corner on the web

Bonus information:- I would like to connect the RFM12 to my Arduino Ethernet board

So now I am a little confused :~ Do you still think it is possible to connect other components like the RFM12 to the Arduino Ethernet SPI line ? I will off course use an other CS (digital output) than used for the SD-card and Ethernet.

Do you still think it is possible to connect other components like the RFM12 to the Arduino Ethernet SPI line?

Conditionally, yes. Is this the device?

edit: If not, a link to the hardware would be helpful.

The hardware that I would like to connect to the SPI i shown on the following link, where you also have a link to the datasheet:

I guess that it depends on, whether the SS have to be "high" or "low" when communicating over the SPI line ?

Good guess, but it depends on the supply voltage. The data pins will handle 0.5v above the supply voltage. If the supply voltage is 3.3v, then max voltage on any pin is 3.8v. That would require a logic level converter.

BTW, slave select LOW is SPI active on this device.

I can handle the 5V / 3.3 V conversion - no problem.

Regarding the high/low CS I understand your answer and from the datasheet, that the RFM12 is "active low". I guess that it means, that the CS have to be low when using the RFM12 and, I have to deactivate the Ethernet and SD-card when using the RFM12 ! Is this correct ?

That is correct. All other SPI interfaces must be disabled while accessing the selected device. There is another topic here that deals with the same thing. Take a close look at the setup function in that sketch.

edit: The slave select lines in the SD and w5100 library are handled by the low level transfer functions. All client.read() and client.write() functions take care of that device slave select line for you. They are very much like the readMax() function in the link above. Enable SPI, transfer, disable SPI, return.

Thanks for your input - I will try to get it up running and come back if I get stucked.

Thanks for your time and input.