Home/Support/Support Forum/XBee temperature sensor problem

XBee temperature sensor problem

0 votes
I would like to know how to read correctly data from XBee analog input (AD0) where I have and LM35.

I show the results in a GLCD but they are wrong. I think I am not reading correctly the data.

This is the loop code:

void loop()
{
if (Serial.available() >= 21)
{
if (Serial.read() == 0x7E)
{
for (int i = 0; i<18; i++)
{
byte discard = Serial.read();
}
// Copy analog samples
int analogHigh = Serial.read();
int analogLow = Serial.read();
int analogValue = analogLow + (analogHigh*256);
temp = (analogValue*1200.0)/1023.0;
temp = temp/10;
GLCD.CursorTo(0,2);
GLCD.print("C = ");
GLCD.print(temp);
}// if start
}// if available
}

Thank you in advance
asked Oct 27, 2014 in RF Solutions and XBee by Ferrerovi New to the Community (3 points)

Please log in or register to answer this question.

1 Answer

0 votes
You need to use a level shifter between the sensor and the XBee modules ADC line as the XBee's ADC line supports 0 - 1.2V and your sensor supports 4 - 30 V.
answered Oct 29, 2014 by mvut Veteran of the Digi Community (13,077 points)
...