Arduino > Arduino communication


I try to establish a communication between two arduino boards. The sending board ist powered through USB and the receiving board through an external power supply. I connected the TX pin form the sending to the RX pin of the receiving board and inverse( TX-RX, RX-TX). I also added a 10k resistor between RX and ground.

This is the code I use:

For sending

void loop() {
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second

For receiving

  void loop() {
  if(Serial.available() > 0) {            // read the incoming byte:
    serIn = '1';
    serIn =;
    switch (serIn) {
    case 'h':
      digitalWrite(ledPin, HIGH);
    case 'l':
      digitalWrite(ledPin, LOW);

This all seems real simple. Unfortunately it doesn't work the way is should. The communication is unstable. It works for some seconds and then waits till it works again after some seconds.

I didn't find any tutorial or forum entry that explains how to make an arduino > arduino communication so i'm looking for some help here. Thank you


yes that would be inherently unstable for a number of reasons: - no hardware handshaking ( i.e. pins that control data flow) - extremely small serial port (UART) buffers in the Atmega chips,, - sometimes one chip will be doing something else when it should be listening for serial data, in which case the port overflows.

Two-pin ( i.e. RX and TX ONLY ) connections work fine during upload as the code has been carefully written to get around the things above. Such a connection is probably not going to work so well between two Arduinos. You could try something like the XBee modules, which have pins for hardware handshaking, so you could actually do some flow control. They also have much larger buffers in their serial hardware, so data won't get lost as easily.

Lots of people want to network their Arduinos, so keep thinking about it ... maybe together we can come up with a cheap workable solution, something like network shield?


If anyone wants to volunteer, I want to be able to use SPI. One Arduino would be configured as a slave; I/O would optimally be triggered by an interrupt handler (use an interrupt pin as the slave CS). If the slave needs to initialte communications, use an additional line from the slave to the master's interrupt.

The nice thing about SPI is that it's a bus - three wires plus one CS per slave. I2C is a bit simpler, but much slower, too.