Xbee + TMP36 Help!

I’m having a lot of trouble with my xbees. I’m trying to get an analog reading from temperature sensor TMP36.

All I seem to get is

7E 00 0A 83 56 78 30 00 01 04 00 03 F6 80
7E 00 0A 83 56 78 30 00 01 04 00 03 F6 81
7E 00 0A 83 56 78 30 00 01 04 00 03 F6 81
7E 00 0A 83 56 78 30 00 01 04 00 03 F6 81

I keep getting 03F6 over and over again…no matter what settings I try.
My Vref is connected to +5v
If I unplug Vref my 03F6 changes to 03FF (maxing out)

//TMP36 10mV/degree Celsius sensor with 500mv zero degree offset value.



#define NUM_ANALOG_SAMPLES 4

int tempC; //Temp in C
int packet[14];
int DataObtained;

int analogSamples[NUM_ANALOG_SAMPLES];

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

}

void loop() {
  readPacket();
}

void readPacket() {
  delay(200);
  if (Serial.available() > 0) {
    //      BeginningFlag = 1;
    //            Serial.print("Setup 2 Complete ");
    int b = Serial.read();
    if (b == 0x7E) {

      //      BeginningFlag = 1;
      packet[0] = b;
      packet[1] = readByte();
      packet[2] = readByte();
      packet[3] = readByte();
      packet[4] = readByte();
      packet[5] = readByte();
      packet[6] = readByte();
      packet[7] = readByte();
      packet[8] = readByte();
      packet[9] = readByte();
      packet[10] = readByte();
      packet[11] = readByte();
      packet[12] = readByte();
      packet[13] = readByte();
      packet[14] = readByte();
     
      
  
      int apiID = packet[3];
      if (apiID == 0x83) {
        analogSamples[0]=packet[14];
        printPacket(14);
        //    int analogSample = (packet[15] << smiley-cool | packet[16];

        //    Serial.println(analogSample);   

        //analogSamples[0] = (packet[11] << 8) | packet[12];
        analogSamples[1] = (packet[11] << 8) | packet[12];    //The reading is taken from these 2 packets.
        //analogSamples[2] = (packet[15] << 8) | packet[16];
/*
        Serial.println(analogSamples[0]);   
        Serial.println(analogSamples[1]);   
        Serial.println(analogSamples[2]);   
        //      delay(1000);
       
*/
        DataObtained = 1;

      }}}
    int reading = analogSamples[1];  // pin 19 ; Use [0] if using pin 20
     Serial.print("Sample Reading = ");
     Serial.println(reading);
    // convert reading to millivolts
    float v = ((float)reading / 1023.0) * 1200.0;
Serial.print("v - millivolts = ");
Serial.println(v);

    // convert to Celcius.  10mv per Celcius degree with 500mV offset at 0 celcius
    float c = (v - 500.0) / 10.0;
Serial.print("Celcius = ");
Serial.println(c);
    // 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();
    }
  }
}

Circuit:

Sensor is connected to +5v, GND, Pin 19
Xbee is connected to +5v, GND, Vref+, Sensor(pin19)
Other xbee is connected to +5v,GND,Tx,Rx via an Arduino

Settings:
Co-ordinator : Sensor

Channel - 0 0
Pan ID - 0 0
Destination Add High - 0 0
D. Add Low - 1234 5678
MY ( 16 bit source ) - 5678 1234
SH - 13a200 13a200
sl - 407B2853 407B2DAE
mac mode - 0 0
retry - 0 0
random delay slots - 0 0
node discover time - 19 19
node discover options - 0 0
cordinator enable - 1 0
scan channels - fffe 1ffe
scan duration - 4 4
end device association - 0 0
co - ord ass - 0 0
associatoin indi - 0 0
aes encryption enable - 0 0
aes encryption key - ky ky
node identifier - CO-ORD SENSOR_1

Power level - 4 4
CCA Threshold - 2c 2c

Sleep mode - 0 0
Time before sleep - 1388 1388
Sleep cycle period - 0 0
Disassociated cylce sleep period - 3e8 3e8
Sleep options - 0 0

Interface Data Rate - 3 3
Parity - 0 0
Packetization Timeout - 3 3
Api Enable - 1 1
Pull - up registers - FF ff

D8 - 0 0
D7 - 0 0
D6 - 0 0
D5 - 0 0
D4 - 0 0
D3 - 0 0
D2 - 0 0
D1 - 0 2
D0 - 0 0
IU ( i/p o/p enable) - 1 1
IT ( samples before tx) - 1 1
IC (DIO Change detect ) - 0 0
IR ( sampling rate) - 0 1000

I/O Input Address - FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
t0-d0 - ff ff
t1-d1 - ff ff
t2-d2 - ff ff
t3-d3 - ff ff
t4-d4 - ff ff
t5-d5 - ff ff
t6-d6 - ff ff
t7-d7 - ff ff
po (Pwm 0) - 1 1
p1 (PWM 1) - 0 0
PT (PWM O/p timeout) - ff ff
RSSI PWM Timer RP - 28 28

Device type ident - 10000 1000
Ct-at Command mode timeout - 64 64
Gt (Guard times) - 3e8 3e8
cc (Command sequence character) - 2b 2b

The code you posted is for the receiving end? I think we need to see the code for the sending end.

I have the TMP36 sensor plugged directly into the XBee and letting the Xbees ADC take care of it.

Would it be easier to send the data from the TMP36 to another arduino and then output the info to the Xbee?

I checked the output of the sensor with a DMM and its around 0.70v so that's not the problem.

Ah ok I have the picture now I think. Which model XBee are these?

They are the Series 1 1mW.

Just seems like I've tried every configuration imaginable and i keep getting 3F6.

Well I haven't worked with the S1 modules, but I do have the product guide. There's really not much information there about the ADC so I assume it is straightforward. But I don't think I'd put 5V on the VREF pin (or on any other pin for that matter, XBees are 3.3V beasts and are not 5V-tolerant).

I'm using them on the sparkfun explorer. Should be fine. I'm thinking of ditching the explorer and.trying to run them on a sparkfun breakout board using 3.3v.

I just don't know what to try anymore

I don't believe any of the Sparkfun XBee explorers do any conditioning on the VREF pin. Have you tried hooking VREF to the 3.3V pin on the explorer?

omg that was it! I had no idea the Vref wasnt regulated..but i guess it makes sense. Thank you! :grin:

So now if i wanted to connect more analog sensors i just have to set them to ADC and read the specific packets in my code right?

Ex. 7E 00 0A 83 00 00 37 00 01 04 00 00 [ FA ]46 FA here is my data for DIO1 so if i enable DIO0 and DIO2 i would read more of my packet and it would look like this?:

7E 00 0A 83 00 00 37 00 01 04 00 00 [XX] [FA] [xx] 46

Hey! Good deal! I think that's the way it works ... give it a shot and let us know!