8

I am trying to use the two temperature sensors TMP36 (from Sparkfun Inventor's kit) and KEYES LM35.

In read TMP36 Sensor and I convert the result to Celsius using the following code:

// TMP36 input sensor -> degrees Celsius calculation
TM36reading = analogRead(TM36sensor);  
TM36voltage = (TM36reading/1024.0)*5.0;
//converting from 10mv per degree with 500 mV offset
//             (TMP36 voltage - 500mV) times 100)
TM36degreesC = (TM36voltage - 0.5) * 100; 

In read LM35 Sensor and I convert the result to Celsius using the following code:

// LM35 input sensor -> degrees Celsius calculation
LM35reading=analogRead(LM35sensor);    // reads the LM35 output
LM35voltage = (LM35reading/1024.0)*5.0;
LM35degreesC=LM35voltage*100.0;    

I have connected also a LCD display to monitor visually the values of these two sensors. Here is my full code. I use also a serial log. Here is a sample from this serial log (as you can see there is a difference/offset between 0.5 to 0.9 Celsius).

TM36: 17.38, LM35: 16.60 diff -> 0.78
TM36: 16.89, LM35: 16.11 diff -> 0.78
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 17.87, LM35: 16.60 diff -> 1.27
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 16.89, LM35: 17.09 diff -> 0.20
TM36: 17.38, LM35: 17.09 diff -> 0.29
mean difference between sensors: 0.48
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 17.38, LM35: 16.60 diff -> 0.78
TM36: 16.41, LM35: 17.58 diff -> 1.17
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 16.89, LM35: 17.09 diff -> 0.20
mean difference between sensors: 0.71
TM36: 17.38, LM35: 16.60 diff -> 0.78
TM36: 16.89, LM35: 16.60 diff -> 0.29
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 17.38, LM35: 16.60 diff -> 0.78
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 17.38, LM35: 16.11 diff -> 1.27
TM36: 17.38, LM35: 17.09 diff -> 0.29
TM36: 16.89, LM35: 16.11 diff -> 0.78
mean difference between sensors: 0.93

I power the Arduino from the computer using the USB cable. When the computer is ON we have the offset that I already demonstrated above. When the computer is turned off (after computer shutdown), immediately the sensor of TMP36 falls around 1 Celsius.. And then both sensors have similar temperature. Arduino powered by USB and Computer ON versus Computer off (LM35 and TMP36 temperature sensors)

Why there is this temperature difference between TMP36 and LM35 sensors? How can we "fine tune" these sensors to monitor the real temperature?

  • Not sure if this applies (I'm a total newbie to Arduino), but this link (learn.adafruit.com/tmp36-temperature-sensor) has a section at the bottom called "Problems you may encounter with multiple sensors". Might be something to review and see if it applies to your case. – PatrickSteele Dec 23 '14 at 17:47
5

The sensors have different accuracy, according to their datasheets. The TMP36 has ±2°C typical accuracy, while the the LM35 has 0.5°C typical accuracy (over 25°C). Read the datasheet carefully and pay attention to the characteristics, more specifically to the accuracy error graphs for each sensor. At your measured temperature (~17°C), you should expect the following error (the red line is not super accurate, but should give a general clue):

LM35:

LM35 Accuracy Error characteristics as per datasheet

TMP36:

TMP36 Accuracy Error characteristics as per datasheet

In addition, as Michal stated, you might have noise in your circuit, and you are not connecting the TMP36 as per the datasheet suggests (note the capacitor between +V and Ground):

TMP36 typical application as per datasheet

  • Thanks for the detailed charts.. I will try to use the 100nF Capacitor next days (I have to buy one first). – ggia Dec 24 '14 at 9:33
  • That's good, and might help a bit, as long as you understand that you will still see differences between the two sensors because of different characteristics. – Omer Dec 24 '14 at 9:40
3

There are many things, first different sensors have different accuracy or they may not have been calibrated from the factory. In addition both are analog and analog reading is susceptible to noise. My guess is there is a high frequency noise on power line coming from the computer interfering with your readings. Try putting a small (100nF) capacitor between AREF and GND pin. You can always just take median of the measured values as the actual temperature.

  • I read here that Arduino Mega already has a capacitor 100nF connected between AREF and GND. I will try to buy next days a 100nF and try to see if the noise is filtered in that way. Thanks. – ggia Dec 24 '14 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.