Inaccurate result when combining LM35 + XBee

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
cutie_lovely_92
 
Posts: 21
Joined: Fri Jan 04, 2013 3:59 am

Inaccurate result when combining LM35 + XBee

Post by cutie_lovely_92 »

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

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?

User avatar
adafruit_support_bill
 
Posts: 88141
Joined: Sat Feb 07, 2009 10:11 am

Re: Inaccurate result when combining LM35 + XBee

Post by adafruit_support_bill »

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

cutie_lovely_92
 
Posts: 21
Joined: Fri Jan 04, 2013 3:59 am

Re: Inaccurate result when combining LM35 + XBee

Post by cutie_lovely_92 »

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

Code: Select all

#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
The Xbee connected to PC through Xbee USB shield.
The Xbee connected to PC through Xbee USB shield.
photo.JPG (432.42 KiB) Viewed 961 times
The Xbee shield v1.1 connected to Arduino UNO R3. The LM35 is on the breadboard, mark with red box.
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 961 times

User avatar
adafruit_support_bill
 
Posts: 88141
Joined: Sat Feb 07, 2009 10:11 am

Re: Inaccurate result when combining LM35 + XBee

Post by adafruit_support_bill »

Appears to be wired right. But your raw reading is at max scale. You should contact the seller of the LM35.

User avatar
Yeoh
 
Posts: 3
Joined: Fri Dec 11, 2015 12:43 pm

Re: Inaccurate result when combining LM35 + XBee

Post by Yeoh »

I face same problem when combining my LM35 +Xbee series 1 pro.
i connected Vref to Vcc on xbee explorer. as i read the data sheet the adc input voltage is 3.3v. My program on calculation suppose to *3.3v but I still unable to achieve proper reading.



#include <SoftwareSerial.h>]

SoftwareSerial xbee(0, 1); //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*3.3*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
1419861_1118098388230596_1088169112_n.jpg
1419861_1118098388230596_1088169112_n.jpg (111.85 KiB) Viewed 333 times
1418368_1118098378230597_247592876_n.jpg
1418368_1118098378230597_247592876_n.jpg (108.97 KiB) Viewed 333 times

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”