What is the best way to connect two Arduinos? I am using XBee

Hello Guys,

I am using two Arduinos for my robot, one is responsible for sensors and data collection at the moment. and the other is supposed to control the motors and probably I will add some other stuff.

I want these two to efficiently talk to each other. I am thinking to use two XBees and make them communicate via wireless. in addition, I will need these Xbees for uploading my code to the arduino.

Any suggestions, how efficiently connect these two Arduinos.

I appreciate your help

Thanks

From your description it sounds your Arduinos are not far away from each other, probably within a few cm or inches. Then it's much better to connect them by wire because it's faster and much more reliable. You can choose between SPI, I2C and UART for the wire transfer, the decision for one depends on your experience and programming skills.

Code update via XBee is nothing easy, you most probably have to change the bootloader to do so.