Raspberry Pi and multiple arduino communication

Hi there. I am working on some project and I need to communicate between 5 arduino boards and Raspberry Pi. Communication needs to be bidirectional. Raspberry needs to send 5 different commands to arduino, and arduino has to send 2 different commands. Comand can be a number ,a string, inpuls whatever. Is it possible with SPI or I2C or what and how it can be done I dont know these stuff?
Thanks for any help!

Sounds like an ideal use case for RS485. Have a read:

Is this what you think?

Yes, that's what I'm referring to. Complication, perhaps - in your concept, does the Arduino send the command at will, or can it simply do this as a response to a "do you have anything to say?" poll from the Raspberry? RS485 works well as a single-controller, multiple-servant system, where the controller sends commands and no one else talks until told to do so.

what is the distance between the nodes?
what is the environment, e.g. urban, countryside with trees, etc
if short distances consider USB - plugging an Arduino into a RPi USB port creates a serial port (COM port on Windows)
if short distance consider WiFi, e.g. using an ESP32 to communicate with the RPi
Longer distance (100's of metres) consider LoRa, e.g. ESP32-Long-Distance-LoRaWan

So arduino need to send command when raspberry ask it to do that so i think that is the thing i will try first.

Distance is 20cm max it is in one box.

I would suggest USB is the simplest - use a USB expender to get extra serial ports
how will you power the devices?
what language will you use on the RPi? I tend to use Java

Python is my main programming language. I have never programmed in java and my main code for that project is written in python and has 5000 lines so I use python.

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