SPI 1 master 2 slaves communication

Hi,
i am making a little project and having a few problems...
The situation at the moment:

  • 1x Arduino UNO (Master)
  • 2x Arduino Nano (Slaves)
  • All connected via SPI

So the slaves have to send data to the master.
The master select one of them and recieve data and after that, the other slave should be selected and send data. The master only has to interrogate the variables of the slaves alternately. That should be as fast as possible.

May ur asking why i´m not using I²C but i can´t do that in the moment cause no more ports and the need of speed.

Is that possible, or do you have to have two masters and one slave?
Or is there another way to communication?

Thank you for reading, I look forward to your answers!

1 Like

lucastrahlendorff:
Hi,
i am making a little project and having a few problems...
The situation at the moment:

  • 1x Arduino UNO (Master)
  • 2x Arduino Nano (Slaves)
  • All connected via SPI

So the slaves have to send data to the master.
The master select one of them and recieve data and after that, the other slave should be selected and send data. The master only has to interrogate the variables of the slaves alternately. That should be as fast as possible.

May ur asking why i´m not using I²C but i can´t do that in the moment cause no more ports and the need of speed.

Is that possible, or do you have to have two masters and one slave?
Or is there another way to communication?

Thank you for reading, I look forward to your answers!

have a look at Nick Gammon's page for Arduino SPI:

hope that helps

Thx for your answer, I will take a look at it!

The following diagram depicts a schematic representation of your SPI Port based project:
multicomSPI.png

Objectives to meet
//===============================================================
1. When K1 is pressed down/released, Slave-1 will send the temperature value of LM35 sensor to Master. The Master will receive the value and will show it on Serial Monitor.

2. When K2 is pressed down/released, Slave-2 will send the temperature and humidity value of DHT11 sensor to Master. The Master will receive the values and will show them on Serial Monitor.
//===============================================================

Start from this tutorial.

multicomSPI.png