Go Down

Topic: Project 3 Love-o-meter: TMP doesn't seem to work (Read 21503 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. :)

Go Up