XBEE communication problems

I've been trying to get my XBEEs to communicate with each other and nothing seems to be going right.

I've tried several tutorials and videos but I think i'm doing something wrong.

I have:
2- XBee Series 1 1mw
1 - Arduino Mega 1280
1 - analog temp sensor

I'm trying to read a temp sensor through DI0 and send the info to my base station which is the arduino and another xbee. They are connected through TX/RX.

I've changed the PANID, MY, DL, all to match. I set DI0 to ADC and connected VRef, GND, +Vcc

This is the output that I'm getting through the serial monitor

7E 00 0A 83 00 00 38 00 01 02 00 03 F6 48
Temp: 0
7E 00 0A 83 00 00 38 00 01 00 00 00 00 43
Temp: 0
7E 00 0A 83 00 00 38 00 01 00 00 00 00 43
Temp: 0
7E 00 0A 83 00 00 38 00 01 00 00 00 00 43
Temp: 0
7E 00 0A 83 00 00 38 00 01 00 00 00 00 43
Temp: 0
7E 00 0A 83 00 00 38 00 01 00 00 00 00 43
Temp: 0
7E 00 0A 83 00 00 38 00 01 00 00 00 00 43
Temp: 0
7E 00 0A 83 00 00 38 00 01 00 00 00 00 43
Temp: 0

Nothing seems to change when i introduce hot or cold air.

// Wireless Temp Sensor Project
// http://nootropicdesign.com/projectlab/2009/11/01/wireless-temperature-sensor/
// SRG - deleted the code that displays the temp on LCD display
// ilium007 - modified code to support TMP36 10mV/degree Celsius sensor with 500mv zero degree offset value.


#define NUM_DIGITAL_SAMPLES 12
#define NUM_ANALOG_SAMPLES 4

int tempC; //Temp in C
int packet[32];
int digitalSamples[NUM_DIGITAL_SAMPLES];
int analogSamples[NUM_ANALOG_SAMPLES];

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

}

void loop() {
  readPacket();
}

void readPacket() {
  if (Serial.available() > 0) {
    int b = Serial.read();
    if (b == 0x7E) {
	packet[0] = b;
	packet[1] = readByte();
	packet[2] = readByte();
	int dataLength = (packet[1] << 8) | packet[2];

	for(int i=1;i<=dataLength;i++) {
	  packet[2+i] = readByte();
	}
	int apiID = packet[3];
	packet[3+dataLength] = readByte(); // checksum

	printPacket(dataLength+4);

	if (apiID == 0x92) {
	  int analogSampleIndex = 19;
	  int digitalChannelMask = (packet[16] << 8) | packet[17];
	  if (digitalChannelMask > 0) {
	    int d = (packet[19] << 8) | packet[20];
	    for(int i=0;i < NUM_DIGITAL_SAMPLES;i++) {
		digitalSamples[i] = ((d >> i) & 1);
	    }
	    analogSampleIndex = 21;
	  }

	  int analogChannelMask = packet[18];
	  for(int i=0;i<4;i++) {
	    if ((analogChannelMask >> i) & 1) {
		analogSamples[i] = (packet[analogSampleIndex] << 8) | packet[analogSampleIndex+1];
		analogSampleIndex += 2;
	    } else {
		analogSamples[i] = -1;
	    }
	  }
	}
    }

    int reading = analogSamples[1];  // pin 19 [0] is pin 20

    // convert reading to millivolts
    float v = ((float)reading / 1023.0) * 1200.0;

    // convert to Celcius.  10mv per Celcius degree with 500mV offset at 0 celcius
    float c = (v - 500.0) / 10.0;

    // round to nearest int
    tempC = (int)(c + 0.5);
    Serial.print("Temp: ");
    Serial.println(tempC);
  }
}


void printPacket(int l) {
  for(int i=0;i < l;i++) {
    if (packet[i] < 0xF) {
	// print leading zero for single digit values
	Serial.print(0);
    }
    Serial.print(packet[i], HEX);
    Serial.print(" ");
  }
  Serial.println("");
}


int readByte() {
    while (true) {
	if (Serial.available() > 0) {
	return Serial.read();
    }
  }
}

I know the code works because someone else is using it. I think my problems are coming from the settings on the Xbees.

Help?

Forgot to mention that I'm using the Xbee Explorer regulated from Sparkfun on both Xbees.

I've changed the PANID, MY, DL, all to match.

All to match what?

This is the output that I'm getting through the serial monitor

If you do not get data from the remote XBee, why are you printing anything to the serial monitor? If you are getting stuff from the remote XBee, how can the issue be XBee configuration?

What temp sensor are you using? How is it connected to the XBee?

I set DI0 to ADC and connected VRef, GND, +Vcc

Connected them to what?

All to match what?

PANID = 5555 on both. Both on Channel C
Xbee #1 :
Changed Destination Address Low - 13A200
Destination Address High - 407B2853

Xbee #2
Changed Destination Address Low - 13A200
High - 407B2DAE
These are just the Xbee's addresses to communicate with each other.

What temp sensor are you using? How is it connected to the XBee?

I am using the TMP36. Connected to +5v, GND, and output pin is connected to DIO0 on the Xbee

I set DI0 to ADC and connected VRef, GND, +Vcc
Connected them to what?

The Xbee has the following connected:
Vref(Pin 14) is connected to +5v, GND is connected to GND, and +5v is connected to +5v, DIO0 is connected to output of sensor.

Xbee #1 :
Changed Destination Address Low - 13A200
Destination Address High - 407B2853

Xbee #2
Changed Destination Address Low - 13A200
High - 407B2DAE

These values do not look right for series 1 models.

Here's a picture of my Xbees. Series 1 1mW from Sparkfun XBee 1mW Wire Antenna - Series 1 (802.15.4) - WRL-08665 - SparkFun Electronics

It looks like they are communicating. ( Dout, Din flash at the same time on both) but my values still aren't write.

7E 00 0A 83 55 55 40 00 01 04 00 03 F6 94
Temp: -49
7E 00 0A 83 55 55 48 00 01 04 00 03 F6 8C
Temp: -49
7E 00 0A 83 55 55 49 00 01 04 00 03 F6 8B
Temp: -49
7E 00 0A 83 55 55 46 00 01 04 00 03 F6 8E
Temp: -49
7E 00 0A 83 55 55 45 00 01 04 00 03 F6 8F
Temp: -49
7E 00 0A 83 55 55 41 00 01 04 00 03 F6 93
Temp: -49
7E 00 0A 83 55 55 41 00 01 04 00 03 F6 93
Temp: -49
7E 00 0A 83 55 55 3D 00 01 04 00 03 F6 97
Temp: -49

I have the Sample rate (IR) set to 1000 and Pin 19 is ADC

Xbee #1 (connected to the temp. sensor )
I changed
DIO1 to ADC
Sample Rate = 1000
My = 5555
DL,DH to match other Xbee #2

Xbee #1
I changed
MY = 5554
DL,DH to match Xbee #1

Is this all i need to change?

bump

:[

Did you modify the code since you're using Series 1 XBees?

I was under the impression that this code was for Series 1?

7E 00 0A 83 00 00 39 00 01 02 00 03 F6 47
Temp: -49
7E 00 0A 83 00 00 37 00 01 02 00 03 F6 49
Temp: -49
7E 00 0A 83 00 00 39 00 01 02 00 03 F6 47
Temp: -49
7E 00 0A 83 00 00 37 00 01 02 00 03 F6 49
Temp: -49
7E 00 0A 83 00 00 38 00 01 02 00 03 F6 48
Temp: -49
7E 00 0A 83 00 00 35 00 01 02 00 03 F6 4B
Temp: -49
7E 00 0A 83 00 00 34 00 01 02 00 03 F6 4C
Temp: -49

This is what I have now. Still not working.

My Xbee Configuration:

*Receiver ( Connected to PC)

XB24 Function: XBEE 802.15.4 Version 10ED
Channel: C
PANID: 5555
DH - 13A200
DL - 407B2DAE
MY - 0
SH - 13A200
SL - 407B2853
CE - 1
AP - 2
DD highlighted itself Blue but I did not change it - 0

*Transmitter (Connected to TMP36)

XB24 Function: XBEE 802.15.4 Version 10ED
Channel: C
PANID: 5555
DH - 13A200
DL - 407B2853
MY - 0
SH - 13A200
SL - 407B2DAE
CE - 0
AP- 2
D0 - 2 (ADC)
IR - 500
DD - This is also highlighted but set at 10000. I didn't change it either.

Yegaman:
I was under the impression that this code was for Series 1?

From the website at the top of the code: "I have Series 2 radios, so if you are using Series 1, you need to read the correct documentation for your radios and modify the code."

It also looks like your API identifier isn't 92 like theirs is. It looks like yours is 83 like mine. I'm working on something similar so I'll let you know if I figure out how to get the analog data out of the API structure (I'm guessing it's different that this code has).

Someone with Series 1 modules took the code and modified it to work with his modules. I think he just left the documentation.

Yeah I noticed the identifier and switched it to 83 earlier but still no change.

I asked in your thread but i'll ask again here.
Can I know what configurations you used for your project? Are they similar to mine?

bump :frowning:

I have xbee series 1, just as I want to make a network to send temperature data and the arduino receives them and likewise can be displayed on the serial monitor of arduino, know how to change the truth if my strength is hardware, but programming is difficult if I, if I say that line of source code will have to modify the appreciate in advance.

here it is:

/ * This program was written for the Arduino Uno The One has an XBee Series 2 RF Module connected to it as a coordinator. The One uses the XBee coordinator to comunicate with two router or end point XBees with temperature sensors. This program recieves the temperature readings from the two endpoint XBees and writes the data to the serial monitor * /

/ * Each Xbee has a unque 64 bit address. The first 32 bits are common to all XBee. The Following four ints (each holds an address byte int) hold the unique 32 bits of the second half of the XBee address * /
int addr1;
int addr2;
addr3 int;
addr4 int;
sen3Counter int = 0; / / This variable counter is used print sensor 3 seconds every 5

void setup () {
Serial.begin (9600); / / start the serial communication
}

void loop () {
if (Serial.available ()> = 21) {/ / Wait for XBee coordinator to recieve full frame
if (Serial.read () == 0x7E) {/ / Look for porque 7E is the start byte
for (int i = 1; i <19; i + +) {/ / Skip through the frame to get to the unique 32-bit address
/ / get each byte of the XBee address
if (i == 8) {addr1 = Serial.read (); }
else if (i == 9) {addr2 = Serial.read (); }
else if (i == 10) {addr3 = Serial.read (); }
else if (i == 11) {addr4 = Serial.read (); }
else {byte discardByte Serial.read = (); } / / Else throwout byte we do not need it
}
Serial.read analogMSB = int (); / / Read the first byte analog data
Serial.read analogLSB = int (); / / Read the second byte
float volt = calculateXBeeVolt (analogMSB, analogLSB) ;/ / Convert values ??to analog voltage values
Serial.println (indentifySensor (addr1, addr2, addr3, addr4)); / / get identity of XBee and print it
Serial.print ("Temperature in F:");
Serial.println (calculateTempF (volt)); / / calculate temperature value from voltage value
}
}
delay (10); / / delay to allow operations to complete
/ / This if else statement is used to print sensor 3 value every 5 second to match the XBee routers
/ / It uses the delay () function above to calculate 5 seconds
if (sen3Counter <500) {+ + sen3Counter; }
else {
Serial.println ("Temperature sensor 3 from:") ;/ / This is sensor 3
Serial.print ("Temperature in F:");
/ / Calculates the Following line voltage, then temperature, and then prints to serial monitor temp
Serial.println (calculateTempF (calculateArduinoVolt (analogRead (A0))));
sen3Counter = 0; / / reset counter back to zero to start another 5 seconds
}
}

/ / Function Takes in the XBee address and returns the identity of the Xbee That sent the temperature data
IndentifySensor String (int a1, int a2, int a3, int a4) {
Rout1 int [] = {64, 176, 163, 166}; / / Arrays are the 32 bit address of the two routers XBees
rout2 int [] = {64, 177, 63, 221};
if (a1 == Rout1 [0] == a2 && Rout1 [1] && a3 == Rout1 [2] && a4 == Rout1 [3]) {/ / Check if Sensor 1
return "from Temperature sensor 1:"; } / / Temp data is from one XBee
else if (a1 == rout2 [0] == a2 && rout2 [1] && a3 == rout2 [2] && a4 == rout2 [3]) {/ / Check if Sensor 2
return "from Temperature Sensor 2"; } / / Temp data is from two XBee
else {return "I do not know this sensor"; } / / Data is from an unknown XBee
}

/ / this function Calculates temp in F from temp sensor
calculateTempF float (float v1) {
float temp = 0;
/ / calculate temp in C, .75 is 25 volts 10mV per degree C.
if (v1 <.75) {temp = 25 - ((75-v1) / 01); } / / If below 25 C
else if (v1 == 75) {temp = 25; }
else {temp = 25 + ((v1 - .75) / .01); } / / If above 25
/ / convert to F
temp = ((temp * 9) / 5) + 32;
return temp;
}

/ / This function Takes an XBee analog pin reading and converts it to a voltage value
calculateXBeeVolt float (analogMSB int, int analogLSB) {
analogReading analogLSB + = int (analogMSB * 256); / / Turn the two bytes into an integer value
float volt = ((float) analogReading / 1023) * 1.23; / / Convert the analog voltage value to a value
volt return;
}

/ / This function Takes an Arduino analog pin reading and converts it to a voltage value
calculateArduinoVolt float (int val) {
float volt = (float) val * (5.0 / 1023.0); / / convert ADC value to voltage
volt return;
}