Hi, i will have one main unit of Arduino and 2-3 other Arduinos as sensors.
I thinking what is simples way to two way communication between them on wire with max length of 10m. There will be almost no data between them but if it will goes it will be important ;). Sensor need to send one command when activated, and get command to light color led or not. Speed and transmission type is unimportant, just the simples way to communicate them.
What part do you want to be simple? There are usually compromises to be made e.g.,
use wireless very simple from an installation point of view, can be battery powered so no restrictions on placement of sensors
create a single wire protocol is very simple aka cheap but more difficult from a protocol point of view
use multiple wires is very simple from a protocol point of view because you can separate IN vs OUT and clock signal. This eliminates timing issues. But this requires more wires.
another important point is what peripherals do you have available just UARTs and I/O or maybe a CAN bus peripheral
I have a project I want to use a Mega as master and some Uno's as slaves, I tried to look into SPI, but is seamed overly complicated. So now I'm think of using serial. one channel for each slave. So that would let me have 4 (?) slaves on one Mega.
I want to use I2C, but the slaves are connected to their own BMS-chip (BQ76940) via I2C, and they have fixed adress. So the Uno's can be on the same I2C net.
You mention wired links (as opposed to wireless) between your devices, so as per the suggestion by @aarg in #2, why not use RS-485? You only need one serial port to talk to several slave devices.
What you are asking about is the hardware interface, e.g. SPI, I2C or UART. The protocol details how the data is packaged up and sent/acknowledged over the chosen hardware interface.
I see now that I could have spesified a little more, as you can not read my mind.
The wiering is no problem. Or it is actually prefered as I can have only one powersupply for all controllers.
The RS-485 would in my case be an unneccesary harware layer. I dont think my envirement is that noisy, and it is just a couple of meters wire max. If I have some trubble with noise, I wil try using shielded cable.
The SPI is fine in regards to wireing. I was thinking about the code, sorry for not beeing clear on that.
SPI might not be more conplicatet that I2C or UART, but as far as I understand both I2C and URAT have dedicated input-buffer in hardware. SPI does not?
So the SPI-code needs cearfull timing with interrupts, atleast on the slave side. There might be the same on I2C and UART, but then it is hidden in the library some where.