I am using a TMP36 and an Arduino (like shown in the diagram below) to measure temperature.
The temperature sensor sensor is changing values abruptly. It looks like there is an error.
Can you please tell me if this is normal or not?
For the information I soldered additional wires to theTMP36 so that I can attach it somewhere next to a metal (but avoided short circuiting it.) I don't know if that changes anything in the reading.
The code looks like this:
int sensorPin = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int reading = analogRead(sensorPin);
float voltage = reading * 5.0;
float calculated = voltage /= 1024.0;
float temperature = (voltage - 0.5) * 100 ;
Serial.print("voltage is "); Serial.println(voltage);
Serial.print("calculated is "); Serial.println(calculated);
Serial.print("temperature is "); Serial.print(temperature) ;Serial.println(" degrees C");
Serial.println("");
delay(1000);
}
The result looks like this:
{}
formatting button for code. (Make sure it's all indented properly.) \$\endgroup\$pinMode(sensorPin, INPUT);
\$\endgroup\$