I am trying to use the Arduino Uno with the LMT86LP temperature sensor, but I am getting strange output voltages from the sensor.
I have the pins (from left to right, flat side facing forward) as VDD, OUT, and GND. VDD is connected to 5V, GND to GND, and Vout to A0 (analog pin 0). The readings from the Arduino are consistently around 360 mV but should be somewhere around 1800 mV as I measured the output of the sensor using a multimeter and got a constant 1.8 V.
Right now the code is very simple. I am just doing analogRead()
and printing to the Serial Monitor.
1 Answer 1
The result from analogRead()
is in counts of full scale, not in volts. Since you are using a 10-bit ADC, full scale is 1024.
1.8V/5V⋅1024=368.64
-
Ah I see, thank you. However I seem to be getting negative values for the temperature. The calculations I am doing are like so, int vin = analogRead(A0); float mV = (vin/1024.0)*5000; float tempC = (mV-500)/10;user1982824– user19828242015年07月09日 20:48:57 +00:00Commented Jul 9, 2015 at 20:48
-
@user1982824: Why are you subtracting 500?Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2015年07月09日 20:51:49 +00:00Commented Jul 9, 2015 at 20:51
-
Sorry sorry, this actually what I'm doing, voltage = reading * (5.0 / 1024); tempC = (voltage - 0.5) * 100; and I'm getting values around 12.5 celsiususer1982824– user19828242015年07月09日 21:00:43 +00:00Commented Jul 9, 2015 at 21:00
-
@user1982824: That equation doesn't match anything I can find in the datasheet.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2015年07月09日 21:08:37 +00:00Commented Jul 9, 2015 at 21:08
-
should i be using the equation T = (10.888 - sqrt((-10.888)^2 +4*.0035*(1777.3-temp))/(2*-0.00347)) + 30user1982824– user19828242015年07月09日 21:12:02 +00:00Commented Jul 9, 2015 at 21:12