Home/Support/Support Forum/How I need configurate Xbee 802.15.4 to send temperature parameters?

How I need configurate Xbee 802.15.4 to send temperature parameters?

0 votes
Itry to make projectlike this: http://nootropicdesign.com/projectlab/2009/11/01/wireless-temperature-sensor/ but using 802.15.4 xbee modules

Iconfigure sensors like shown in this link: http://www.digi.com/support/kbase/kbaseresultdetl?id=2180

In recieving end i get:
7E 00 1C 83 56 78 1F 00 05 06 00 03 FF 03 FF 03 FF 03 FF 03 FF 03 FF 03 FF 03 FF 03 FF 03 FF 70
Temp: 0
7E 00 1C 83 56 78 1F 00 05 06 00 03 FF 03 FF 03 FF 03 FF 03 FF 03 FF 03 FF 03 FF 03 FF 03 FF 70
Temp: 0

and my 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 [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 < 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();
}
}
}

What i need to change, to get real temperature?
related to an answer for: any idea how can i do that?
asked Jun 4, 2014 in IEEE 802.15.4 by Roksters New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
What voltage level does your sensor run at?
answered Jun 4, 2014 by mvut Veteran of the Digi Community (15,355 points)
...