Best protocol/way to simply connect 2-3 Arduinos to main Arduino

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.

Any ideas?

I would consider RS-485.

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.

Any other protocol to consider?

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.

Sounds reasonable....

@MikkelD Welcome to the forum.

SPI is actually simple; it just needs a few wires more than I2C and UART for a single connection. For that you get

  • one data wire for each direction (Master -> Slave, Slave -> Master)
  • a clock signal that tells the slave when the data is valid and when the data line gets updated
  • one chip select signal for each slave

This makes SPI faster and more robust than I2C and UART.

In your case you would need 7 lines and could use just one SPI peripheral.

If you have 4 hardware UARTs on your Mega that can work as well.

Thanks for all the replys.

I see now that I could have spesified a little more, as you can not read my mind. :stuck_out_tongue:

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.

Well, you seem to know exactly what you need. That makes it kind of pointless to offer advice.

if you want span 10m either use
RS232 or
RS485, for example in a Modbus RTU
Or CAN Bus
Or Ethernet

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.