Sending data from one Arduino to another Arduino

Hello, I am working with an Arduino that is connected to sensors measuring distances. I want to send this data to another Arduino that will be controlling other devices using this information.

I have limited knowledge using the SDA and SCl lines to send information, is this the only way to send information to another Arduino?

If so, what would be the basic code for this master/slave configuration of lets say and array of integers or single integers that can be transferred to form the array.

In conclusion, I want the array of collected data of one Arduino and be able to use this information by Another Arduino. Thanks.

Alternatives to I2C are serial and SPI. For I2C master slave example code, look at the Wire library examples.

You could also use the Software Serial port on each. In my case, I use the Wemos D1 Mini for the sensors and communicate with them using MQTT over WiFi.

How far apart are the Arduinos?

That will partly determine which connection/communication method is most suitable.


Thanks for the replies. The Arduinos will be about 6-8 inches apart.