Need help with choosing communication protocol

My project has 5 arduinos performing different task like measuring weight with load cell, controlling motors, triggering lights. I would like to put all the data collected by the arduinos on a common channel so that I can access them from a master controller/ Raspberry Pi and also give commands back to the arduinos. Which protocol among I2C, SPI, CAN will best serve my purpose. Please feel free to suggest any other protocol other than these.

Thanks

I think Modbus RTU/ASCII (via RS-232/285/422) or Modbus TCP (via WiFi or Ethernet) is suitable for you

qikp:
Which protocol among I2C, SPI, CAN will best serve my purpose. Please feel free to suggest any other protocol other than these.

You need to provide more information. For example ...

  • What is the distance between the Arduinos?
  • How many times per second (or per minute) must messages be passed?
  • How long is a message?
  • Can one of the Arduinos be appointed as the master so that it can request data from each of the others in turn?
  • Do you want to use a wired connection or wireless?

And why not just use a single Arduino to do everything?

...R

What is the distance between the Arduinos? => about 1 meter at max.

How many times per second (or per minute) must messages be passed? => 1 msg per second
How long is a message? => 1 Byte
Can one of the Arduinos be appointed as the master so that it can request data from each of the others in turn? => Yes , this is possible
Do you want to use a wired connection or wireless? => Wired would be preferable

SPI has the advantage that it is designed for multiple connections whereas Serial is intended as 1 to 1 but can be hacked to be 1 to many. I am not really familar with I2C. I think it is a one-way-at-a-time system whereas SPI and Serial use 3 wires so can send and receive.

My inclination would be to use SPI. The MOSI MISO and SCLK wires are common to all the devices and each slave needs to have a separate ChipSelect wire so that the master can identify which slave it intends to communicate with. There also needs to be a GND connection between the master and the slaves.

...R

Of the three you mention only CAN will be reliable if the signals leave the board. You can also look at RS485 for communications. If you do the RS485 consider it a 3 wire buss, the ground acting as the third wire. Many problems have been solved by adding the ground wire.

qikp:
What is the distance between the Arduinos? => about 1 meter at max.

why do you need multiple Arduinos within 1 Meter?
why can’t you connect all sensors/actors o one Arduino?
Before you state “running out of pins” … have you considered to use one Controller with more pins?
Provide a schematic drawing of your installation including measurments between your sensors.

gilshultz:
Of the three you mention only CAN will be reliable if the signals leave the board.

I suspect that SPI will work perfectly well unless the OP's system is operating where there is a lot of external electrical interference. I know that Serial and I2C do and from an electrical point of SPI is similar.

...R