temperature negative and false with a TMP36

Hi everyone !

I tried to use a TMP36 with my Arduion Uno with this sensor. I just would like to acquire the temperature and display it on the monitor. But, i have a negative temperature (- 35 °C, -25°C ...) and it changes all the time.

Thank you in advance.


My programm is here:

int sensorPin = 0;

void setup() { Serial.begin(9600); }

void loop() {

int reading = analogRead(sensorPin);

float voltage = reading * 3.3; voltage /= 1024.0;

Serial.print(voltage); Serial.println(" volts"); Serial.print(reading); Serial.println(" reading");

float temperatureC = (voltage - 0.5) * 100 ;

Serial.print(temperatureC); Serial.println(" degres C");

delay(60000); }

I suggest you should use

int sensorPin = A0;

instead of

int sensorPin = 0;

You seem to be assuming in the code that the analog reference is 3.3V:

float voltage = reading * 3.3;

but you are using a Uno and you haven't called analogReference. Therefore, the reference voltage is approximately 5V, and you need to change the 3.3 to 5.0.

Thank you. I change the “3.3” to “5.0” and “int sensorPin = A0” but there is the same problem.

I can see that :

97 reading
-2.64 degres C
0.49 volts
100 reading
-1.17 degres C
0.43 volts
88 reading
-7.03 degres C
0.38 volts
78 reading
-11.91 degres C
0.44 volts
91 reading
-5.57 degres C

I have connect the output of the TMP36 in Analogue A0, the Vcc of the sensor to “power 5V”. As the datasheet recommended i use a capacitor (100nF) between Vcc and GND.

Try this code:

int sensorPin = A0; int reading=0; float temp=0

void setup() { Serial.begin(9600); }

void loop() {

reading = analogRead(sensorPin); //reading will have a value between 0-1023

temp = reading * 0.488759; // the number comes from: (5(volts)*100)/1023

Serial.print(reading); Serial.println(" reading"); Serial.print(temp); Serial.println(" degres C"); delay(1000); }

Ok I tried this code. I have several temperatures but they are false (35°C ) for exemple and it changes all the time. I don't understand these results, maybe i didi a mistake with the board. Thank you.

Ok, for that I think you just need to change the value (0.488759) to something else -I'm not sure what though :( . Check the datasheet of your sensor.

The same code worked fine for me, I was using LM35 and I did not need any capacitor.

I'm also new at this :)

Can you measure the voltage between the TMP36 output pin and ground, using a multimeter?

Maybe you confused the BC transistor and the TMP36 sensor.

Arduino Starter Kit comes with five BC transistors and only one TMP36 sensor; if these are your first experiences, you could have confused them since they look similar on the manual.