Project 03 - Faulty TMP36?

Hey guys. I just completed project 3 and all wiring / code seems to be correct and functional.

However, when examining the serial port, I’m getting some weird temp readings.

Without applying heat, I am getting a consistent baseline temperature reading, but once heat is applied (by touching the sensor with a finger for 2-3 seconds) the readings climb almost immediately to temperatures in excess of 80 degrees celsius, logically causing all three LEDs to light up and messing up the experiment.

Is this a problem with the TMP36 itself or with my code or wiring? I’m attaching my serial port readings, and the code I’m using is here:

const int sensorPin = A0;
const float baselineTemp = 17.38;
void setup() {
  for(int pinNumber = 2; pinNumber<5; pinNumber++){
    digitalWrite(pinNumber, LOW);
void loop() {
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  // convert the ADC reading to voltage
  float voltage = (sensorVal/1024.0)*5.0;
  Serial.print(", Volts: ");
  Serial.print(", degrees C: ");
  // convert the voltage to temperature in degrees
  float temperature = (voltage - .5)*100;
    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);

thanks for any advice you can give me :slight_smile:

Hi, I'm having the same problem right now. I experimented by removing the LED display code and it seems related: when I comment out the LED section I get accurate readings again.

I was able to find another forum message mentioning that, when the Arduino is powered by a laptop via USB, and driving some load (even LEDs), the power supply is an issue and might lead to inconsistent readings.

I think you could check the same: comment the LED display code and see if your readings return to normal. I'm also going to try and use some external power supply to see if both sections can be made to work at the same time.

Just to recap what worked for me:

  • I switched to use an external power supply via the jack (not drawing power from the USB port). To do this, I borrowed a switched 12V DC power supply from another device and plugged it into the Arduino's jack (beside the USB port)
  • I also changed the placement of my 5V pin on the + rail on the breadboard to make sure 5V and GND were not side by side (not sure why this worked, but it did)

My Project 03 is now working and the sensor's readings do not spike up like they used to as soon as the first LED was switched on.


Thank you! I’m going to test your method out and see if it works. Appreciate the tips!


I also had the same problem.

Moving further away from one another the 5V pins on my breadboard worked for me! Thanks.