analogRead not giving the same value on different USB Vin

I have a TMP36 that I use to display the temperature in the room on a LCD screen.

I then convert the analog read Vout of the TMP36 to voltage and then the voltage to Celsius.

I uploaded the code using my laptop. The temperature it gave me was about 25 ?. But then I plugued the USB on my tower PC just to power it stationary and the temperature it was giving me got up to 27 ?. I know the 27 ? is about right because I have a thermometer in my alarm clock (I know right) and it gives me about 27 ? too. When I plug it back in my laptop, the temperature displayed drops to about 25 ?. It is not a constant value as it changes to +- 1 ? as normal.

The TMP36 works on voltage from 2.7V to 5.5V. I use the 5V out on my arduino to power it. Changing the Vin on the TMP36 should not change its output as long as the voltage stays in the range. (I tested it using a potentiometer and a multimeter.)

So the problem is, could the different computers output a different voltage and/or amperage? This change should not affect the TMP36, but could it affect the reading of the analog port?

If you are using the default analog reference voltage you very well could get different results in different computers. The default analog reference is Vcc which will be the USB voltage. Measure Vcc supplied by USB on the different computers. You always see analogRead(A0) * 5.0/1024 but it should be analogRead(A0) * Vcc/1024. And, yes, I use 1024, not 1023. Just because it makes sense to me

yea Im also measuring temperature for the first time using TMP36...

I compare to temperature using my multi-meter and its way off... from the same locale...

so Im wondering about the conversion formula... or the accuracy of either the TMP36 OR my multi-meter!

how would you guys debug this one?

the Multi-meter is a Brymen 869s - they are pretty decent multi-meters and I suspect it should be pretty accurate...

Im seeing almost a 10C difference between them...

TMP36 on Arduino reading 19C
and
Brymen 869s Multi-Meter reading 28.7C

any thoughts?

cheers

now that i left it running - i can see its getting worse... looks like the reading is dropping over time - it's gotten down to 12c :fearful:

i know thats not right... it's hot here and I'm in shorts... not my winter pants by the beach yet.

Same as before. Measure the Vref with your meter and use that in the reading conversion not 5V.
If your Vref is changing then it will change what you read.

Ok I checked the voltage coming off the center pin of the TMP36 - and it appears to almost agree with the multi-meter in this case.

when I see voltage = .65 from the serial output of the Arduino... I see about that much on my multi-meter... +/- .03 volts or so...

so .65 on serial....and .63 on the multimeter... I think thats pretty good... no?

that leads me to believe the temperature conversion formula is wrong or bad?

from the Arduino Projects book:

float temperature = (voltage -.5 ) * 100;

any thoughts?

Ok if someone sees this please check my math.

I looked up the specs on the TMP36

here:

http://www.analog.com/static/imported-files/data_sheets/TMP35_36_37.pdf

Low voltage operation (2.7 V to 5.5 V) Calibrated directly in °C
10 mV/°C scale factor (20 mV/°C on TMP37) ±2°C accuracy over temperature (typ)
±0.5°C linearity (typ)
Stable with large capacitive loads
Specified ?40°C to +125°C, operation to +150°C Less than 50 ?A quiescent current
Shutdown current 0.5 ?A max

Specified operating range temperature is -40 to 125 = 165 degree range of possible values?

i did it this way... range = 165 possibly values
the chart shows something between 0-1700mV as the readable range of the middle pin
i got a reading of .66v = 660mV

660/1700 = .388 = 38.8% of the range of the device.

165 X .388 = 64.02 ( 38.8% of 165 possible points )

64.02 - 40 = 24.02 ( remove the negative values possible gives you the reading from zero which according to my temperature locally is very close! )

I expected to see 24C - for my house and my town....

IF instead I use the value from the TMP36 of 750mV = 25C and I say its 10mV per 1C

i get what the Arduino book says... which is

750mV - 660mV = 90mV difference... which should mean 90/10 = -9 degrees offset from 25C = 16C

which is what the serial output is showing - when I follow the directions and instructions according to the Arduino Projects Book...

Can anyone explain that one? seems like something is wrong.... I could just be my math or my logic...

but the reading on the Arduino does NOT agree with my expected reading - and the TMP36's own center point and 10mV for degree change also doesn't compute for me...

Halp?

:slight_smile:

ok I just missed your comment to use Vcc

so we SHOULD be measuring voltage reference coming in to the Arduino from the USB port?

whats the best way to do that? is there a simple way to grab that reference or am I just supposed to read the + out?

cheers

The simplest way of automatically measuring the Vcc and hence the Vref, is to switch the A/D input and mere the internal referance voltage. Then from this reading you can work out the value of Vcc.

Google for example code of this.