LMT84 vs. TMP36G - Both Technically Working, but Something Wrong!

Hello,

I'm using the LMT84 Temperature sensor from T.I (http://www.ti.com/lit/ds/symlink/lmt84.pdf)

I'm trying to compare it to the TMP36G which I know has been reading accurate temperatures for me for some time now.

My code:

const int tempPin = A0; // LMT84 
float tempC = 0; 
const int temp36 = A1; //TMP36G
float tempC36 = 0; 

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

void loop()
{
 //Temp:  
  int tempRead = analogRead(tempPin);
  float tempmV = ((float) tempRead) / 1024.0 * 5000; 
  tempC = ((5.506 - sqrt(sq(-5.506) + (4 * 0.00176 * (870.6 - tempmV))))/(2 * -0.00176)) + 30; //LMT84 temp sensor transfer function
  Serial.println("LMT84 Temp Sensor: "); 
  Serial.print("Analog: "); Serial.println(tempRead);
  Serial.print("mVolts: "); Serial.println(tempmV,4);
  Serial.print("Temp: "); Serial.println(tempC, 4);
  
  
  int tempRead36 = analogRead(temp36); 
  float tempVolt = (float) tempRead36 / 1024.0 * 5.0; 
  float tempmV36 = tempVolt * 1000; 
  tempC36 = (tempVolt * 100.0) - 50.0;  // this was for the TMP36 sensor
  Serial.println("TMP36 Temp Sensor: "); 
  Serial.print("Analog: "); Serial.println(tempRead36);
  Serial.print("mVolts: "); Serial.println(tempmV36,4);
  Serial.print("Temp: "); Serial.println(tempC36, 4);
      
 delay(1000);
}

My Circuit:
I have two seperate 10nF caps, one for the LMT84 (3.2 kOhm resistor to Vout to 10nF to ground [as data sheet says]) and the other cap for the TMP36 (Vout to 10nF to ground). Then each of their respective Vout's goes to A0 and A1 respectively.

I also attached the results from the Arduino Serial Terminal, their temperatures are completely off. But it seems to be at consistent difference of either 6.225 C or 5.7367 C.

My multimeter is fairly accurate for each of the Vout values shown on terminal, the LMT84's temperature is correct ACCORDING to the table in the datasheet I posted above, so my transfer function in the IDE should be correct. And I know the TMP36G has been giving me correct temp readings, so what's going?! I know I have to be doing something incorrectly. I've been digging and digging, with no luck.

As always any insight or direction is greatly appreciated.

Cheers,
UST

cap for the TMP36 (Vout to 10nF to ground)

The data sheet for the TMP36 shows that cap going from Vsupply to ground.

What are the readings like when you move the cap over?, or use two caps one on Vs and the other on Vo?

When I was using this sensor I remember seeing different values based on the cap position.

Hey Cattledog thanks for the reply !

Yes you are correct, when I have no cap, the values are all off. When I have 1 cap on Vo-Gnd it's correct, when I have 1 cap on Vs-Gnd the temp is down by 0.5-1C , and when I have a cap on Vo and Vs, nothing changes.

But the LMT84's is currently reading 22-23.5 C , while the TMP36G is reading 17-17.8 C which seems more accurate cause right now it is freezing where I am working!

Could I be doing something wrong in the way I am converting my readings?

 tempC = ((5.506 - sqrt(sq(-5.506) + (4 * 0.00176 * (870.6 - tempmV))))/(2 * -0.00176)) + 30; //LMT84 temp sensor transfer function

You must be close, because when I look at the data sheet http://www.ti.com/lit/ds/symlink/lmt84.pdf the lookup table shows that you should be between 28 and 29 C for the 879mv shown in the printout.

Hey thanks for another reply cattledog!

You are absolutely right, that is what I was saying. According to the LMT84 datasheet, the printout on the Serial Terminal for voltage and temperature is correct. But 28 C just can't physically be correct, it's freezing in my work space, this is why the subject heading is what it is :stuck_out_tongue:

The LMT84, according to the datasheet, multi-meter, and Serial printout etc. it is reading correctly, but physically I know it just can't be correct at all.

The TMP36G, I know from past working with it, that it is correct, also it represents more closely what the thermostat is reading.

However, both of these can't be right which is why I was sure it was something to do with the way I was coding; but that seems to be in order (maybe I overlooked something?). So maybe I have the hardware hookup for the LMT84 done incorrectly?

10nF caps, one for the LMT84 (3.2 kOhm resistor to Vout to 10nF to ground [as data sheet says])

Try it without the resistor and the capacitor on the output. My understanding of the capacitance of the Arduino ADC is that it is below the 1100pf and you don't need the resisitor. With the 10nf capacitance you added, the resistor is specified and you should have been OK but you won't hurt anything to try without.

You could try the LM84 with the cap between Vcc an ground as a bypass like on the other TMP36.

The data sheet talks about moisture and leakage currents on the output causing inaccurate results, so I'd check for any contamination on your pins or board that could be causing leakage.

I've seen reference to stabilizing analog read with multiple reads and a delay.

analogRead(tempPin);
delay(10);
  int tempRead = analogRead(tempPin);
  float tempmV = ((float) tempRead) / 1024.0 * 5000;

The first analogRead() will switch the pin to the ADC. The delay will allow the voltage at the ADC to stabilize and the second analogRead() should get a stable value.

Fantastic advice, really appreciate the detail. I will give this all a shot as soon as I can and I will promptly post my findings! Thanks again :smiley:

Alright I got it working, this is what I did:

  1. 100uF Cap over the power and ground line for the board
  2. No additional caps or resistors for the LMT84
  3. I changed this line:

float tempmV = ((float) tempRead) / 1024.0 * 5000;

to this line:

float tempmV = (((float) tempRead) / 1024.0 * 5000) + 40;

So that I could match the miliVolt reading on the LMT84 data sheet, to better replicate the TM36G. I realize this might be a work around, but both temperatures are roughly the same; and I know the LMT84 is better spec'd sensor, so I could effectively replace the TM36G.

Thanks again for all your help, really appreciate it!

PS: Posted results below !

EDIT/UPDATE: Realize now that the temperature is still a little off, don't know if this is because the LMT84 is more sensitive or something else. Might tweak that "+40" value to see if I can better replicate a result.

UST_:
float tempmV = ((float) tempRead) / 1024.0 * 5000;

Hi
We are using LMT84 for our class project. Your code is a great help for me. May I ask why your are multiplying resolution by ''5000''? Is this value ''5000'' ref voltage?
Thanks