affect of analog reference voltage

Dear all,

I am using two sensor

  1. LM 35 sensor
  2. Hallsensor

Reference voltage 5v . Intially i tried code with 5v where i found LM 35 temprature sensor keep deviating output. When i check calibration process

as taking 1.1v The output of sensor get stabilized. But hallsensor reads 0A .

Can some one suggest me what exactly happening.

below code i get stabilized out for temperature sensor. if i uncheck internal voltage(use 5v as reference) keep fluctuating but i read hall sensor value properly.

float temp;
static int temp_int;
int temprature_reading;
float voltage=0.0;
float ANALOG_SCALING=0.004887585532746823;
int Current;
int Current_Reading;
int  Take_Temp_Reading()
{

  temp = float(analogRead(A5)) * 110 / 1024.0;
  temp_int=(int)(temp*100.0);
  return(temp_int);
  // Serial.print("Temp"); Serial.println(temp);
}
int Hall_Sensor_Reading()
{
  int  val = analogRead(analogPin);
  voltage=val*ANALOG_SCALING;
  current=(int) ((voltage*12.5)-31.25);
  return(current);
}


void setup()
{
  Serial.begin(9600);
  analogReference(INTERNAL);
}

void loop()
{
  temprature_reading=Take_Temp_Reading();
  Serial.print("temprature_reading:");
  Serial.println(temprature_reading);
  Current_Reading=Hall_Sensor_Reading();
  Serial.print("Current_Reading:");
  Serial.println(Current_Reading);
  Serial.println(".....................................");
  delay(1000);

}

Two thoughts ...

How much is the LM35 deviating ? Maybe you could average a few readings or just ignore changes within a certain range.

You can programmatically change the voltage reference between reads - but you probably need to allow a little time for the ADC to settle at the new reference. Read the Atmel datasheet.

...R

What hall sensor are you using as it may be putting out a 0-5V signal so needs the 5V reference.

As Robin2 says you will need to allow settle time when changing ADC reference & pins. I tend to discard the first ADC reading and then read again.