Search code examples
embeddedavr32

Reading incorrect temperature value from thermistor using EVK1100


I want to get the temperature from a thermistor, so I made a voltage divider (3.3V to 10k resistor and between ground a 10k thermistor) I read the ADC between the 10k resistor and the thermistor. The BCOEFFICIENT is 3977, the NOMINAL TEMPERATURE is 25C and I use the simple B parameter equation. I'm not sure where I'm doing mistake, I read room temperature as 10.5C which was suppose to be around 24C. The following is the part of the program that I used for temperature sensor(developed in AVR studio),

 #define TEMPERATURENOMINAL 25
 #define TERMISTORNOMINAL 10000
 #define BCOEFFICIENT 3977
 #define SERIESRESISTOR 10000
{
float ke1,tempa,xin
ke1 = adc_get_value(peak_adc2,peak2);
xin=(1023/ke1)-1;
xin=SERIESRESISTOR/xin;
tempa=xin/TERMISTORNOMINAL;
tempa=log(tempa);
tempa/= BCOEFFICIENT;
tempa+=1.0/(TEMPERATURENOMINAL + 273.15);
tempa=1.0/tempa;
tempa-=273.15;
dip204_set_cursor_position(1,3);
//sprintf(ui, "Temp is %.2f deg", Ref);
sprintf(ui, "Temp is %.2f deg", tempa);
      dip204_write_string(ui);
}

I checked the voltage using multi-meter for instance in between the thermistor and 10k resistor and in the EVK 1100 using the following line

ke1 = adc_get_value(peak_adc2,peak2)*3.3/1024;

I get the same voltage in both. Not sure where I'm doing a mistake, Hope someone guide me in right direction


Solution

  • Your code looks correct to me, and I suspect a hardware problem may be the culprit.

    It seems likely you have inadvertently connected two 10K-ohm pull-up resistors between the ADC input and the +3.3V reference: perhaps one is already populated on the EVK1100 board, and you have added another one externally connected to your thermistor. This would be equivalent to putting both 10K-ohm resistors in parallel with each other, which would be equivalent to a 5K-ohm resistor in series with the thermistor. At 25°C, the thermistor resistance Rt would read 10K ohms, which would produce a voltage of:

    +3.3V * (Rt / (Rt + 5K))
    
    = 2.20V
    

    instead of the correct +1.65V. This number is very close to the result you are seeing (+2.17V @ 24°C).

    You can verify this hypothesis by looking at the schematic and/or PCB for the EVK1100 to see if a 10K-ohm pull-up resistor is connected from the ADC input to +3.3V. If this is the problem, remove one of the two resistors and you should see correct behavior.