I always got the wrong value of LM35....

I am new here to study the Arduino. I used the Arduino DUE and a LM35DZ to measure the room temperature. I connected all the pins to Arduino, and I thought the connection is right. Vcc-5V AOUT-A0 GND-GND And I wrote the programm:

define TempPin A0

void setup(){ Serial.begin(9600); } void loop(){ int T=analogRead(TempPin); Serial.println(T); float Temp=5 * T* 100 / 1024; But I got an wrong value T is 1023,and Temp=499... Then I measured the voltage between different pins: Vcc is 1.085V higher than AOUT Vcc is 4.7V higher than GND AOUT is 3.7V higher than GND But I do not know where the fault is. Can someone help me to solve this? thx! :confused:

Do you use the sensor directly or do you use some breakout board? If the later, please provide a link to the product.

Please do not connect the sensors AOUT to the Due if you measure the above voltages as the 3.7V may damage the Dues analog inputs (3.3V max.).

If possible, please post a (sharp) picture of your setup with all wires visible.

The LM35's output is 10 mV per degree C, if room temperature is 25 C the voltage at the LM35 output should be close to 250 mV (0.25 volts) measured to GND, what does your volt meter say? What is the DUE's analog reference voltage?

OK, the DUE's default AREF is 3.3V, default resolution is 10 bit (same as UNO), so:

``````float temp = analogRead(ainPin) * 330.0 / 1024.0;
Serial.println(temp);
delay(1000);
``````

EDIT: OOPS, forgot the " . " . >:(

Assuming your connections are OK and LM 35 is alive,

Use the following formula:

temp in deg C = ( (refVoltage / 1024) * reading ) / 10 ;

refVoltage defined in mV. For example, in UNO internal reference = 1.1 v or 1100 mV.

refVoltage/ 1024 - tells how many mV each count of the reading represents.

multiplying above by the reading from Analog pin gives mV read out.

Finally as LM 35 gives 10 mV for each deg C, you divide by 10 to get the deg C.