# Xbee communication (spot the rookie error)

**URL:** <https://forum.arduino.cc/t/xbee-communication-spot-the-rookie-error/223017>\
**Category:** Networking, Protocols, and Devices\
**Created:** [March 28, 2014, 1:11pm UTC](https://forum.arduino.cc/t/xbee-communication-spot-the-rookie-error/223017 "2014-03-28T13:11:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 28, 2014, 1:11pm UTC](https://forum.arduino.cc/t/xbee-communication-spot-the-rookie-error/223017/1 "2014-03-28T13:11:12Z")

</div>

Hi Everyone

I am having a little trouble implementing communication between two Arduinos (mega 2560) using Xbee Series 1s and the wireless proto shield from Arduino. They are all in transparent mode, and have the latest firmware.

One is sending a number, read from a potentiometer using this code:

```cpp
#include <Potentiometer.h>

Potentiometer potentiometer = Potentiometer(2); //a Potentiometer at analog in 2

void setup(){
  Serial.begin(9600);
}

void loop(){
  Serial.println(potentiometer.getValue(),DEC);
  
  delay (500)
}

```

This is working fine, as I get the right results using an xbee explorer and the arduino serial monitor. However, when I try to receive this on the other arduino, using the following code

```cpp
int incomingByte = 0;   // for incoming serial data

void setup() {
  Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
}

void loop() {

  // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
  }

  if (Serial.available() == 0) {

    // say what you got:
    Serial.println("I received nothing");
  }

  delay (250);
}

```

and using the arduino serial monitor to check the result, I get an output like the following

```cpp
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50
I received: 51
I received: 50

```

for reference it should be more like

```cpp
237
237
237
237
237
237
237
237
237
237
237
237
237
237
237

```

(from explorer)

where am I going wrong? I have swapped around the xbees and have the same problem which ever one recieving

Many thanks as always  
Alex

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 28, 2014, 3:55pm UTC](https://forum.arduino.cc/t/xbee-communication-spot-the-rookie-error/223017/2 "2014-03-28T15:55:55Z")

</div>

Don't worry, had help from another forum. Thanks anyway

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 10:47am UTC](https://forum.arduino.cc/t/xbee-communication-spot-the-rookie-error/223017/3 "2021-05-06T10:47:43Z")

</div>

Closed on May 6, 2021, 10:47am UTC


