Forum Rule: Always post complete source code & details to reproduce any issue!

1. ## measuring Temperature LM35

Hello there,

I'm trying to implement LM35CAZ on teensy 3.2.
i attach the configuration on this thread, and the code i am been using.

https://imgur.com/a/2itS20M

The problem is that i don't know why the measuraments are wrong the values are like 30 ºC and this is
definitely wrong.

If you can help me with this issue i'll appreciate it.

CODE:
float tempC;
int pinLM35 = 15; // i have been using pin 15 for measurements

void setup() {

Serial.begin(38400);
analogReference(INTERNAL); // ¿Is The reference 1.2 V?
}

void loop() {

// Calculating temperature
tempC = (1.2 * tempC * 100.0)/1024.0;

Serial.print(tempC);

Serial.print("\n");

delay(1000);
}

2. Try powering LM35 with 3.3v and get rid of INTERNAL ref and use 3.3 in calculation, and this sketch works for me
Code:
```float tempC;
int pinLM35 = 15; // i have been using pin 15 for measurements

void setup() {

Serial.begin(38400);
//  analogReference(INTERNAL); // ¿Is The reference 1.2 V?
}

void loop() {

// Calculating temperature
tempC = (3.3 * tempC * 100.0) / 1024.0;

Serial.print(tempC);

Serial.print("\n");

delay(1000);
}```
25.46
25.46
25.14
25.14

EDIT: also works with analogReference(INTERNAL); and 1.2 in tempC calculation

I think your wiring is reversed for Vcc and GND. Facing the square face of the LM35, left pin is 3v3, middle analog out, and right is GND. Hopefully, you didn't damage the LM35.

except you should use 3.3v. actually at 25C LM35 voltage output is 0.255 v, so Vcc of 3.3v or 5v should be OK.

3. thank for you help now is working perfectly

4. Recommended minimum supply voltage is 4 Volts (http://www.ti.com/lit/ds/symlink/lm35.pdf) and minimum temperature reported with a single supply is 2 C. I hit this problem before and feed the LM35 from the Vin pin. Also the internal reference voltage is specified as 1.195 Volts.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•