Temperature display code

Hello, I’m trying to make similar project like: http://nootropicdesign.com/projectlab/2009/11/01/wireless-temperature-sensor/, but I’m using Xbee 802.15.4 wireless modules. I configure them like showing in: http://www.digi.com/support/kbase/kbaseresultdetl?id=2180
Base Remote
DL = 5678 DL = 1234
MY = 1234 MY = 5678
P1 = 2 D1 = 2
IU = 1 IR = 14
IA = 5678 (or FFFF) IT = 5

Code is:

#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 = ((d >> i) & 1);
}
analogSampleIndex = 21;
}

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

int reading = analogSamples[1]; // pin 19

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 < 0xF) {
// print leading zero for single digit values
Serial.print(0);
}
Serial.print(packet, HEX);
Serial.print(" “);
}
Serial.println(”");
}

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

And the terminal window:
7E 00 12 83 56 78 23 00 05 04 00 03 FF 03 FF 03 FF 03 FF 03 FF 78
Temp: -49
7E 00 12 83 56 78 23 00 05 04 00 03 FF 03 FF 03 FF 03 FF 03 FF 78
Temp: -49
7E 00 12 83 56 78 23 00 05 04 00 03 FF 03 FF 03 FF 03 FF 03 FF 78
Temp: -49
7E 00 12 83 56 78 25 00 05 04 00 03 FF 03 FF 03 FF 03 FF 03 FF 76
Temp: -49
7E 00 12 83 56 78 23 00 05 04 00 03 FF 03 FF 03 FF 03 FF 03 FF 78
Temp: -49
7E 00 12 83 56 78 23 00 05 04 00 03 FF 03 FF 03 FF 03 FF 03 FF 78
Temp: -49
7E 00 12 83 56 78 28 00 05 04 00 03 FF 03 FF 03 FF 03 FF 03 FF 73
Temp: -49
7E 00 12 83 56 78 23 00 05 04 00 03 FF 03 FF 03 FF 03 FF 03 FF 78
Temp: -49

Any idea how I can get normal temperature parameters?

Look at the value in position 3 (83). Look at the code that tests that value. It is only concerned with API packets of type 0x92 (not 0x83).

I have no idea what P1, IU, IA, IR, or IT are for. I don't see that you are telling the remote (where, presumably, the temperature sensor is connected) that it should be reading an analog pin (I don't think that D1 = 2 does that) or sending analog data in the packet.

So I have to change code to read packages from 0x83 not from 0x92?