measuring Temperature LM35

Status
Not open for further replies.
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() {
tempC = analogRead(pinLM35);

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


Serial.print(tempC);

Serial.print("\n");

delay(1000);
}
 
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() {
  tempC = analogRead(pinLM35);

  // 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.

LM35-temperature-sensor-pinout-1.png
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.
 
Last edited:
Status
Not open for further replies.
Back
Top