Temperature Sensor

Good morning,
I am working on a project that uses the temperature sensor. It's set up with 3 LED lights that turn on when the temperature is 2, 4, and 6+ degrees above the baseline temp. However, I am having trouble setting the baseline. When I first open the serial monitor to see the temp in open air, picture 1 are the readings I was getting. So I set the baseline temp at 23 degrees. When I uploaded the code and put my finger on the sensor, the temps jumped way up as seen is picture 2. So I let the sensor sit a few minutes to see what it would go back down to in open air. It only dropped to the low 50s and never got anywhere near 23 again. So I reset the baseline at 51, uploaded the code again, and put my finger on the sensor. The readings were back down in the 20s.

I cannot figure out how to get consistent readings. Is there a conversion happening that I am unaware of? Or am I reading the baseline wrong?

Any help is appreciated. Thanks!

A link to the datasheet of the used sensor would help, a wiring diagram too and we might need the used source code (don't forget the code tags!).

I am completely new to using the arduino. How do I get the datasheet for the used sensor? The wiring diagram is below. And what is the source code and code tags?

How do I get the datasheet for the used sensor?

That's the manual of the sensor. The vendor of the sensor should provide that information. If you don't got it, it may help to tell us what exact type of sensor you're using.

And what is the source code and code tags?

The source code is all the text (statements, variable declarations, etc.) that is used to build your sketch, the program that runs on the Arduino.
Code tags are used in this forum system to mark source code. Without them the forum system interprets some character combinations specially and the code gets hard to read. The button in the editor to insert code tags is the one with the </> symbol.

pylon:
A link to the datasheet of the used sensor would help, a wiring diagram too and we might need the used source code (don't forget the code tags!).

google: [sensorname] datasheet

Code looks like that for a "TMP36", look closely at the flat side of the sensor with a magnifier, you may have to tilt it around to get the light right before you can see the markings.
With a 5 volt Arduino at room temp of 23°C, the ADC value for a TMP36 should be about 150.

Attached is the TMP36 datasheet. And the following is the code that I used.

const int sensorPin = A0;
const float baselineTemp = 23.0;
void setup(){
  Serial.begin(9600); // open serial port
  for(int pinNumber = 2; pinNumber<5; pinNumber++){
      pinMode(pinNumber, OUTPUT);
      digitalWrite(pinNumber, LOW);
  }
}
void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value; ");
  Serial.print(sensorVal);
  //convert the ADC reading to voltage
  float voltage = (sensorVal/1024.0) * 5.0;
  Serial.print(", Volts: ");
  Serial.print(voltage);
  Serial.print(", degrees C: ");
  // convert the voltage to temperature in degrees
  float temperature = (voltage - .5) * 100;
  Serial.println(temperature);
  if(temperature < baselineTemp){
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
  }else if(temperature >= baselineTemp+6){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
  }
  delay(1);
}

The problem that I keep running into is when I set the baseline temp at 23, upload the code, and then put my finger on the sensor, all three LEDs turn on because the sensor is giving me numbers in the 60s. So I reset the baseline, upload the code, touch the sensor, and the readings are back in the 20s so no LEDs turn on.

Thank you all so much for your help!

TMP35_36_37 Data Sheet.pdf (467 KB)

Attached is the TMP36 datasheet. And the following is the code that I used.

Did you check that you're using a TMP36 sensor or did you just google that based on outsider's speculation?

If you're really using a TMP36 and an Arduino UNO with above code and you get 60°C if you touch the sensor, your sensor is broken and should be replaced. Be sure to never touch the sensor's pins as this would ruin the measurement.

Or the sensor is loose in the breadboard and the code is doing close to 1000 updates per second.

I checked the sensor. It is a TMP36. I will rewire the board and try again.

I have a similar issue. First of all, the baseline appears to be around 26.5, while the thermometer shows 24.4. I've observed that this termometer adds about 1 degree, so the actual room temperature should be around 23 degrees. The second issue is that when I put my fingers around the sensor, it jumps to 60-80, even the reading from tmp36 jumps to 200-250 and pretty much never comes back again until arduino is restarted.

EDIT: After moving 5v and ground wires to other pins on the breadboard the project now works as expected - except for the rather high baseline. Some issue with some of the first power pins on the breadboard.

After moving 5v and ground wires to other pins on the breadboard the project now works as expected - except for the rather high baseline.

The baseline is simply a lower temperature value where the LEDs are programmed to light up. As this value is chosen by you it's up on you to change it if you think it's wrong.

I have a similar issue. First of all, the baseline appears to be around 26.5, while the thermometer shows 24.4. I've observed that this termometer adds about 1 degree, so the actual room temperature should be around 23 degrees. The second issue is that when I put my fingers around the sensor, it jumps to 60-80, even the reading from tmp36 jumps to 200-250 and pretty much never comes back again until arduino is restarted.

Check the voltage of the 5V pin on your Arduino.

The sensor is providing 10mV per °C, so if your body temperature is 37°C it will have 0.87V on it's output. If your USB is only providing 4.7V your sketch will read the temperature as 43°C. If you use sensor with analog output, a constant and dependable supply voltage is key to get correct results.

How is an USB port not stable?

How is an USB port not stable?

Check your's with a multimeter. My computers have voltages from 4.6V to 5.3V on the USB ports.

Most logic circuitry is happy for anything in the 4.5 to 5.5V range, sometimes 4.75 to 5.25V if its fussy.

Analog circuitry is not so casual!

pylon:
Check your's with a multimeter. My computers have voltages from 4.6V to 5.3V on the USB ports.

Getting very erratic voltage ranging from 4 to 5 volts. But anyhow the issue got solved by moving power and ground to different slots on the breadboard.

Noticed a smiliar issue when doing starter kit chapter 5: servo motor. The servo is twitching and constantly trying to adjust a few degrees either way. When running from 9v battery it twitches a few times and then remains still like it should.

This is now the 2nd time something like this happens, which begs the question: if 5v is not actually stable enough for analog systems then shouldn't that be mentioned in the projects book somewhere? I mean, this kit is for beginners and I don't think this quite qualifies as common knowledge for someone not familiar with even the most basic concepts of electricity.

if 5v is not actually stable enough for analog systems then shouldn't that be mentioned in the projects book somewhere?

5V is stable enough for most analog experiments if a battery or external power supply is used but USB-5V is usually not stable enough to use it in real applications. For beginner kits this usually isn't relevant as they are mostly used for playing around and understanding the environment.

Still having trouble with the sensor. I rewired the board with the pins in different places. I opened the serial monitor and was getting room temperature readings around 22. So I set that as the baseline. When I reuploaded the code and opened the serial monitor, I was getting readings around 36. I didn't touch the sensor. So I reset the baseline temperature at 36, uploaded the code, and opened the serial monitor and the readings were back in the 20s. I'm not sure why it jumps from 20s to 30s when I change the baseline temperature in the code and don't touch the sensor.

Finally got it to work by moving the ground to another spot on the board. Don't know why this should matter? Seems like I shouldn't have to keep moving wires around until I find pins that work. Glad it finally worked but I'm a little frustrated.