Problem with analogReference with acceleration and temperature sensor

Hello guys.

I am new at Arduino. Recently I buy Arduino UNO R3, and temperature, acceleration sensor from Lilypad (sparkfun). For temperature I get best reading with analogReference(INTERNAL), but when using this line I cant measure my acceleration. Kinda dont understand really this analogReference. Can someone explain me a bit ? Also help me get this acceleration working with this analogReference included ?

#include <math.h>

//Temperature sensor
unsigned int total; // max 64 readings
float tempC; // final temp

//Acceleration sensor
const int xpin = A1;
const int ypin = A2;
const int zpin = A3;

void setup() {
  analogReference(INTERNAL); // enable the internal ~1.1volt bandgap reference
  Serial.begin(9600);

  pinMode(xpin, INPUT);
  pinMode(ypin, INPUT);
  pinMode(zpin, INPUT);
}

void loop() {

// Temperature
 total = 0; // reset value
   for (int x = 0; x < 10; x++) { // read 10x
     total = total + analogRead(A0); // add each value to a total
     delay(50);
   }
  Serial.print("Analog reading : ");
  Serial.println(total/10);
   tempC = ((total * 0.0001025) - 0.5) * 100;
   //float v = total * 4.9 / 1024;
   //tempC = (v - 0.5) * 100;
  Serial.print("Temperatura : "); 
  Serial.println(tempC -2, 1); // po dokumentaciji in nasih meritvah je -2 potreben

// End of Temperature

// Acceleration
 int x = analogRead(xpin);
  delay(1);

 int y = analogRead(ypin);
  delay(1);

 int z = analogRead(zpin);
  delay(1);

 float zero_G = 512;
 float scale = 102.3;

 Serial.println();
 Serial.print("x : ");
 Serial.println(((float)x - zero_G)/scale);
 Serial.print("y : ");
 Serial.println(((float)y - zero_G)/scale);
 Serial.print("z : ");
 Serial.println(((float)z - zero_G)/scale);
// End of Acceleration
    
    delay(1000); // some delay to slow readings
}

You should provide links to the hardware you use!

analogReference(INTERNAL);

make the internal reference voltage generator (2.5V) the the maximal voltage the input pin can measure. This might work with the temperature sensor (depends on which one you use) but I guess the acceleration sensor provides a range from 0V to 5V, so you're not able to measure that too.

How do you power your Arduino? If you use an external power source (power supply, battery) you should get quite exact measurements for both sensor types but you might need to change the temperature formula because the highest value (1023) isn't 2.5V anymore but 5V.

Powering with the USB connection provides a voltage that has a range from about 4.6 to 5.5V which is not optimal for quality analog measurements. Sensors with digital outputs are usually easier to handle because they don't depend on a stable known voltage that much.

Thank you for your replay.

Accelerometer I use is LilyPad Accelerometer - ADXL335 - DEV-09267 - SparkFun Electronics

Temperature sensor is LilyPad Temperature Sensor - DEV-08777 - SparkFun Electronics

For for power source I use USB from computer atm. Later will buy external one.

pylon:
You should provide links to the hardware you use!

analogReference(INTERNAL);

make the internal reference voltage generator (2.5V) the the maximal voltage the input pin can measure.

On the Uno the internal reference 1.1V (but with significant device spread, so you have to callibrate). Other
Arduinos have other voltages IIRC.

For an acceleration sensor (which are typically ratiometric to the supply), you should use the default
reference of the supply voltage.