Arduino to Arduino - Tutorial Examples and Useful Links

Arduino to Arduino communication can be established in a number of ways using 1 or more wires. radio, i2c, one wire, bluetooth, network, mobile, internet can also be used. This article breifly describes some of these options.

See Arduino to Arduino communication really working

The image above is an example of the Visual Studio Serial Monitor showing the words "blink" that uses these methods to send from Arduino to Arduino.

The mutli serial viewer facility in Visual Studio is unique and very useful in as much that two or more viewers can display data on a pc and also forward the data to two or more connected Arduinos or xbee/bluethooth modules.

This means that with the Visual Studio Arduino plugin we can spy on the Arduino to Arduino communications. This makes programming one arduino to another much easier. In the example below we can see one way "Arduino to Arduino" communications. One arduino is sending and, for the example, one arduino is sending back what it receives. Two way can be enabled simply by setting the "echo" port.

Further reading : More about arduino to arduino serial echo

Programming "Arduino to Arduino" Serial Communications

Serial communication is probably the most common way for two Arduino to talk to each other. Serial means we connect either 1 or two wires from Arduino to Arduino. One wire allows one Arduino to talk and one Arduino to listen. Two wires allows both Arduinos to listen and talk (receieve and send).

Arduino to Arduino serial communication needs to be at an agreed speed such as 115k baud. Some Arduino have one hardware serial port and some have up to 4 hardware serial ports. By ports we mean pins. We can user hardware serial ports at the high speed of 115k or we can use any other Arduino pins as slower rates using a SoftwareSerial librray.

As an example of Arduino to Arduino connection we might connect TX0 on Arduino A to RX0 on Arduino B and RX0 on A to TX0 on B.

The nice thing about serial is that it is easy and well supported. Solution such as the mini xbee radios also use serial. Depending on your location this allows Arduino to Arduino data exchange at distances of up to 50km. Normally we only need a few hundred feet which is satisified using cheaper xbee radios.

To implement hardware serial in our code we declare in the setup() method our intention to use a serial port and specify the required speed. In our example we used (TX/RX0) which is the default Arduino "Serial" port

Serial.begin(115200);

We can connect an Arduino to our computer and use a Serial Monitor application to test our serial messages. The following example will send "Arduino to Arduino example" to the computer connected from USB to the Arduino master serial port. (The master serial port is also the Arduino USB port)

Serial.println("Arduino to Arduino example");

Another way to see two arduino communicate is using the Arduino debugger upgrade for Visual Studio, due for release Aug 2012.

Here is an example of both an Arduino 328 and a mega1280 being monitored at the same time in Visual Studio. The visualizations are open source and just examples. You can create your own instruments and display your own (any) arduino data graphically.

Click the image to read more about the debugger upgrade.