Go Down

Topic: Project 3 Love-o-meter: TMP doesn't seem to work (Read 25250 times) previous topic - next topic


So I am having a problem in this project with the TMP temperature input that is used.  Every time I open the serial monitor, the first value for temperature I get is very low and random. Each value after that is always -50.0, and the sensor value (out of 1023) is 0.  And when I tried to put my finger around the sensor, the readings did not change. Is my TMP not working, or is there another issue I am overlooking?

I believe that the program I wrote is the same as the one written in the kit's book, but I'm not sure, so I will post it below.

const int sensorPin = A0;
const float baselineTemp = 20.0;

void setup(){
  for(int pinNum = 2; pinNum < 5; pinNum++){
    pinMode(pinNum, OUTPUT);
    digitalWrite(pinNum, LOW);

void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  float voltage = (sensorVal/1024.0) * 5.0;
  Serial.print(", Volts: ");
  float temp = (voltage - .5)*100;
  Serial.print(", degrees C: ");
  if(temp < baselineTemp){
  }else if (temp >= baselineTemp+2 && temp < baselineTemp+4){
  }else if(temp >= baselineTemp+4 && temp < baselineTemp+6){


I would suspect a wiring error.  Nothing obvious jumps out about your code.

If you replace the temperature sensor with a potentiometer, can you see the readings change?


Hey did you ever get this working? because I am having the exact same problems as you are. If you did please tell me what you did.


Jul 23, 2014, 12:06 pm Last Edit: Jul 23, 2014, 12:08 pm by Fabio881 Reason: 1
Hi guys!

If you are both (still) experiencing the same problem, I would also start checking for basic wiring issues: the code itself is quite simple, and very similar to what I also used (and which worked).
In particular, the fact that the problem already appears here:

Code: [Select]
int sensorVal = analogRead(sensorPin);

tells you already where to start looking at.
Is the TMP sensor really connected to pin A0 on the Arduino, as declared in the code? Are the connections done properly? (check the datasheet - be aware that the schematic view is from the bottom).
To prove that the component itself has problem, a nice way is to substitute it with a potentiometer, as suggested by the user here above.

Hope it helps a bit


I had similar issues as you. I didn't see anything wrong with the code. What I did is put the baselineTemp to whatever temperature it was in the room. For example:

Code: [Select]
const float baselineTemp 24.8889

Also, I found out that the original delay (delay(1) is too quick and gives an inaccurate reading, so I gave it a delay(1000).
#include <signature.h>


Just make sure you are using a TMP sensor and not a BC547 Transistor. They look very similar and both come with the starter kit ;-)


WOW i can't believe it i thought this BC547 that's a TMP, thanks alot Autmaton, i found the correct sensor in the box. I can't believe that TMP  look's the same like BC547 Transistor. :)


WOW i can't believe it i thought this BC547 that's a TMP, thanks alot Autmaton, i found the correct sensor in the box. I can't believe that TMP  look's the same like BC547 Transistor. :)
And it's true still a year later.

The one TMP36 included in the starter kit looks almost identical to one of the five BC547 transistors that are also included in the kit.  The key bit of knowledge is knowing that there is only ONE loose TMP36 and there are FIVE BC547's on a piece of tape included in the starter kit. Even with reading glasses, a magnifying glass and bright lights, the name of the component is still difficult to read. But it is readable.

That incorrect component had me scratching my head for over an hour until I got to Automaton's post.  Then I REALLY looked and saw my mistake.  And I'm sure a lot of people make the same mistake year after year, month after month, day after day.

-  bob3d

PS  Even with the circuit working correctly, the temperature is still inaccurate by several degrees and it's inconsistent from scan to scan varying in hundredths of a volt which translates to several degrees variability.  Even moving the wiring or components slightly by hand affects the calculated values.  I' was also unsure how accurate that 5.00 volt reference really was. After reading it with a precise voltmeter, it was a rock steady 5.02VDC.

Go Up