Inaccurate result when combining LM35 + XBee
Moderators: adafruit_support_bill, adafruit

Inaccurate result when combining LM35 + XBee

by cutie_lovely_92 on Fri Jan 04, 2013 3:21 am

I am currently doing a project reading Body temperature and pulse sensor that will sent the result wirelessly through XBee.
I started by trying each components separately and everything works fine.

Problem:
Inaccurate result when I combine the XBee and LM35 sensor.
The sensor keep giving the same result. Here's the sketch output.
Code: Select all | TOGGLE FULL SIZE
LM35 Thermometer
Analog in reading: 1023 - Calculated Temp: 109.8
Analog in reading: 1023 - Calculated Temp: 109.8
Analog in reading: 1023 - Calculated Temp: 109.8
Analog in reading: 1023 - Calculated Temp: 109.8



I am very sure that before combining it with XBee everything works just fine.
Can anyone explain to me what's the problem here?
Do it need any voltage adjustment or something?
cutie_lovely_92
 
Posts: 21
Joined: Fri Jan 04, 2013 2:59 am

Re: Inaccurate result when combining LM35 + XBee

by adafruit_support_bill on Fri Jan 04, 2013 6:43 am

Post a photo showing all your connections. And post the code you are using too.
User avatar
adafruit_support_bill
 
Posts: 29736
Joined: Sat Feb 07, 2009 9:11 am

Re: Inaccurate result when combining LM35 + XBee

by cutie_lovely_92 on Fri Jan 04, 2013 12:48 pm

adafruit_support wrote:Post a photo showing all your connections. And post the code you are using too.


Code: Select all | TOGGLE FULL SIZE
#include <SoftwareSerial.h>

SoftwareSerial xbee(2, 3); //RX, TX

int potPin = 0;
float temperature = 0;
void setup()
{
  Serial.begin(9600);
  Serial.println("LM35 Thermometer ");
  analogReference(INTERNAL);
  xbee.begin(9600);
}
void printTenths(int value) {
  // prints a value of 123 as 12.3
  Serial.print(value / 10);
  xbee.print(value/10);
  Serial.print(".");
  xbee.print(".");
  Serial.println(value % 10);
  xbee.print(value % 10);
}
void loop() {
  int span = 20;
  int aRead = 0;
  for (int i = 0; i < span; i++) {
    aRead = aRead+analogRead(potPin);
  }
    aRead = aRead / 20;
    temperature = ((100*1.1*aRead)/1024)*10;
    // convert voltage to temperature
    Serial.print("Analog in reading: ");
    Serial.print(long(aRead));
    // print temperature value on serial monitor
    Serial.print(" - Calculated Temp: ");
    xbee.print(" - Calculated Temp: ");
    printTenths(long(temperature));
   
    delay(500);
}
Attachments
photo.JPG
The Xbee connected to PC through Xbee USB shield.
photo.JPG (432.42 KiB) Viewed 527 times
image.jpeg
The Xbee shield v1.1 connected to Arduino UNO R3. The LM35 is on the breadboard, mark with red box.
image.jpeg (449.51 KiB) Viewed 527 times
cutie_lovely_92
 
Posts: 21
Joined: Fri Jan 04, 2013 2:59 am

Re: Inaccurate result when combining LM35 + XBee

by adafruit_support_bill on Fri Jan 04, 2013 1:13 pm

Appears to be wired right. But your raw reading is at max scale. You should contact the seller of the LM35.
User avatar
adafruit_support_bill
 
Posts: 29736
Joined: Sat Feb 07, 2009 9:11 am