[3/Love-o-meter] it seems TMP36 doesn't work (volts: 0.00 ; degrees: -50.00)

Yes the Transistor looks similar to the Temperature Sensor. They have the same black body with 3 legs though the Transistor outer legs are bent whereas the Temp Sensor I have the legs are all straight.

Anyway I tried a transistor in the circuit and got varying negative readings like those in this thread.

So ensure it's really the Temperature Sensor and not one of the Transistors. In my official kit I got 1X Temp Sensor and 5X Transistors which were taped to a card.

for project love-o-meter This is my code, its from the book, and when I compile it works without errors, when I connected Arduino to it, only the LED that was connected to pin 3 came on, nothing else happened, nothing on the serial monitor, what am I doing wrong

const int sensorPin = A0; const float baselineTemp = 20.0; void setup(){ Serial.begin(9600); 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); float voltage=(sensorVal/1024.0)* 5.0; Serial.print(",Volts:"); Serial.print(voltage); Serial.print(",degrees C:"); float temperature=(voltage-.5)*100; Serial.println(temperature); 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); }

As @arucarn posted, make sure you are using the correct component. The TMP36 temperature sensor looks almost identical to the BC 547B transistor.

If you have the Arduino starter kit then you will most likely have 5 transistors but only 1 temperature sensor.

The temperature sensor has entirely straight legs where as the transistor has straight legs that pinch in at the top.

I don't know if this will help anyone but just in case... I was having similar problems to those listed above with negative reads on my sensor. I checked and double checked the circuit and the code. I was about to give up when I realized it was way hotter in this room than my defined baseline temp, and hotter my max baseline temp +. I changed my baseline to match the actual temp in the room (almost 80 degrees) and it worked.

I have the same problem. Wired correctly, using the code from the site. Normal reading are in the -40s or -50s.

I bought a couple more temperature sensors from the site so I'll try them when I get them.

I was having the same problem with the negative numbers. Turned out I just took the wrong part from the starter kit. Make sure you have the temperature sensor...

Hi there

I've played with this sample and the tmp36 sensor. No problem so far , it was quite straightforward.

Only concern is that sensor output is not really stable, i get this serial output: sensor Value: 146, Volts: 0.71, degrees C: 21.29 sensor Value: 144, Volts: 0.70, degrees C: 20.31 sensor Value: 145, Volts: 0.71, degrees C: 20.80 sensor Value: 144, Volts: 0.70, degrees C: 20.31 sensor Value: 144, Volts: 0.70, degrees C: 20.31 sensor Value: 147, Volts: 0.72, degrees C: 21.78 sensor Value: 144, Volts: 0.70, degrees C: 20.31 sensor Value: 146, Volts: 0.71, degrees C: 21.29 sensor Value: 144, Volts: 0.70, degrees C: 20.31

So my questions are: - is it normal, and is it the correct behaviour of this sensor? - if I want to improve the accuracy, should i change the sensor, the wiring, or focus on the software, with maybe a moving mean?

I've already faced this kind of analogic issue, with a capacitive sensor, and i used a moving mean. It was not really suitable for my purpose because it was for an input device, so adding latency with the computation of the mean was not good.

I'm interested in any suggestion, and quite a newb in electronics. Thanks for reading

Nico

The problem with the negative value will be solved with the answer of Simo_xx: Just use the temperature sensor and not one of the 5 transistors! VERY USEFUL. Thanks Simo_xx. Problem solved :)

Hi everyone,

I ran into a problem where my code has uploaded and everything seems to be connected but instead of lighting up after i touch the sensor. Once i plug in the power source all the LEDs are already lit.

I am not sure what happened here

Small chance this will help someone, in my case it was a goof in the code, mis-wrapped my parens:

wrote: float temperature = (voltage - .5 * 100);

instead of: float temperature = (voltage - .5) * 100;

Just one of those moments (thus a reminder), so make sure you spend some time on the obvious sources of problems if you hit this, particularly if you are seeing a lot of the ~-49C readings.

I have had the same problem...

I used the line float voltage = sensorVal/1024)*5;

However, the correct calculation is float voltage = sensorVal/1024*.0*)*5;

I hope this helps some of you!

Johannes

Hello,

i have a problem with the temperature sensor aswell. In my case it seems to work properly when it starts but as soon as touch it, the temperature jumps to unrealsitic values.

Here is an example:

Sensor Value: 146, Volts: 0.71, degrees C: 21.29 Sensor Value: 147, Volts: 0.72, degrees C: 21.78 Sensor Value: 147, Volts: 0.72, degrees C: 21.78 Sensor Value: 147, Volts: 0.72, degrees C: 21.78 Sensor Value: 147, Volts: 0.72, degrees C: 21.78 Sensor Value: 146, Volts: 0.71, degrees C: 21.29 Sensor Value: 148, Volts: 0.72, degrees C: 22.27 Sensor Value: 157, Volts: 0.77, degrees C: 26.66 Sensor Value: 182, Volts: 0.89, degrees C: 38.87 Sensor Value: 228, Volts: 1.11, degrees C: 61.33 Sensor Value: 228, Volts: 1.11, degrees C: 61.33 Sensor Value: 229, Volts: 1.12, degrees C: 61.82 Sensor Value: 228, Volts: 1.11, degrees C: 61.33 Sensor Value: 228, Volts: 1.11, degrees C: 61.33 Sensor Value: 228, Volts: 1.11, degrees C: 61.33 Sensor Value: 228, Volts: 1.11, degrees C: 61.33 Sensor Value: 229, Volts: 1.12, degrees C: 61.82 Sensor Value: 230, Volts: 1.12, degrees C: 62.30 Sensor Value: 229, Volts: 1.12, degrees C: 61.82 Sensor Value: 229, Volts: 1.12, degrees C: 61.82

Is the sensor defect? I checked the wires and changed the analog pins but nothing helped. I am wondering what is going wrong since everthing looks fine until i try to measure some changes in temperature. The code is correct because the sensor values fits to the other data, but its value itself behaves unrealistic...

Hi,

I have the exact same thing. When you start all is normal, but as soon as you touch the sensor it goes up to the unrealistic high values and won't come down again. When you unplug the Arduino and plug it in again, the sensor returns the correct value again and it all starts over again..

Sensor value: 147, Volts: 0.72, Degrees C: 21.78 Sensor value: 146, Volts: 0.71, Degrees C: 21.29 Sensor value: 147, Volts: 0.72, Degrees C: 21.78 Sensor value: 147, Volts: 0.72, Degrees C: 21.78 Sensor value: 147, Volts: 0.72, Degrees C: 21.78 Sensor value: 146, Volts: 0.71, Degrees C: 21.29 Sensor value: 146, Volts: 0.71, Degrees C: 21.29 Sensor value: 146, Volts: 0.71, Degrees C: 21.29 Sensor value: 146, Volts: 0.71, Degrees C: 21.29 Sensor value: 146, Volts: 0.71, Degrees C: 21.29 Sensor value: 146, Volts: 0.71, Degrees C: 21.29 Sensor value: 149, Volts: 0.73, Degrees C: 22.75 Sensor value: 172, Volts: 0.84, Degrees C: 33.98 Sensor value: 208, Volts: 1.02, Degrees C: 51.56 Sensor value: 208, Volts: 1.02, Degrees C: 51.56 Sensor value: 201, Volts: 0.98, Degrees C: 48.14 Sensor value: 201, Volts: 0.98, Degrees C: 48.14 Sensor value: 201, Volts: 0.98, Degrees C: 48.14 Sensor value: 200, Volts: 0.98, Degrees C: 47.66 Sensor value: 201, Volts: 0.98, Degrees C: 48.14 Sensor value: 200, Volts: 0.98, Degrees C: 47.66 Sensor value: 200, Volts: 0.98, Degrees C: 47.66 Sensor value: 200, Volts: 0.98, Degrees C: 47.66 Sensor value: 199, Volts: 0.97, Degrees C: 47.17 Sensor value: 200, Volts: 0.98, Degrees C: 47.66 Sensor value: 200, Volts: 0.98, Degrees C: 47.66 Sensor value: 200, Volts: 0.98, Degrees C: 47.66 Sensor value: 199, Volts: 0.97, Degrees C: 47.17 Sensor value: 199, Volts: 0.97, Degrees C: 47.17 Sensor value: 198, Volts: 0.97, Degrees C: 46.68 Sensor value: 198, Volts: 0.97, Degrees C: 46.68 Sensor value: 199, Volts: 0.97, Degrees C: 47.17 Sensor value: 199, Volts: 0.97, Degrees C: 47.17 Sensor value: 199, Volts: 0.97, Degrees C: 47.17 Sensor value: 199, Volts: 0.97, Degrees C: 47.17

I've had the same problem as mech_1794 and deterr. If I set my baselineTemp to something much higher, say 70 C, then the temperature sensor works fine (5-10 degree increases in temperature in the monitor when I touch the sensor, and then back down when I remove my hand) but none of the LEDs get activated.

Alternatively, if I set the system to run and touch the TMP36 so that it spikes up and registers temperatures around 70 C, and THEN pull out the LEDs one by one, I see the temperature sensor drop back down 10-20 degrees at a time until it's back in the normal range.

Could there by an ungrounded signal or something causing some interference? Would another resistor connected somehow to the temperature sensor pull down any stray voltage?

I switched the spot where by ground wire was connected (along the same ground rail on the breadboard), and it seems to have fixed the problem.

CzarCW: I switched the spot where by ground wire was connected (along the same ground rail on the breadboard), and it seems to have fixed the problem.

I had the same instability problem, and my 5V wire was connected side-by-side with my ground wire on the breadboard (both at the first pin on top, but on different vertical rails, of course).

Following your advice, I moved the GND connection further down (to the second pin from the top) and the problem is now gone, though for the life of me I cannot figure out how or why.

Thanks!

I had the same issue, it was due to the fact as someone stated, I used BC547 transistor (5 pack in the starter kit) rather than the TMP36 sensor (single similar looking but with 3 straight legs).

CzarCW: I've had the same problem as mech_1794 and deterr. If I set my baselineTemp to something much higher, say 70 C, then the temperature sensor works fine (5-10 degree increases in temperature in the monitor when I touch the sensor, and then back down when I remove my hand) but none of the LEDs get activated.

Alternatively, if I set the system to run and touch the TMP36 so that it spikes up and registers temperatures around 70 C, and THEN pull out the LEDs one by one, I see the temperature sensor drop back down 10-20 degrees at a time until it's back in the normal range.

Could there by an ungrounded signal or something causing some interference? Would another resistor connected somehow to the temperature sensor pull down any stray voltage?

I troubleshooted this down to the LEDs just as you did but instead of pulling them out I ended up toggling the light on then off so that it didn't affect the sensor. There's probably a better way to write this but here's a piece of my code that worked for me:

if(temperature < baselineTemp){
  digitalWrite(2,LOW);
  digitalWrite(3,LOW);
  digitalWrite(4,LOW);
}else if(temperature >= baselineTemp + 2.0 && temperature < baselineTemp + 4.0){
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,LOW);
  //have to turn LED back off not to affect temp sensor
  delay(250);
  digitalWrite(2,LOW);
}else if(temperature >= baselineTemp + 4.0 && temperature < baselineTemp + 6.0){
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
  digitalWrite(4,LOW);
  delay(250);
  //have to turn LEDs back off not to affect temp sensor
  digitalWrite(2,LOW);
  digitalWrite(3,LOW);
}else if(temperature >= baselineTemp + 6.0){
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
  digitalWrite(4,HIGH);
  //have to turn LEDs back off not to affect temp sensor
  delay(250);
  digitalWrite(2,LOW);
  digitalWrite(3,LOW);
  digitalWrite(4,LOW);
}

CzarCW: I've had the same problem as mech_1794 and deterr. If I set my baselineTemp to something much higher, say 70 C, then the temperature sensor works fine (5-10 degree increases in temperature in the monitor when I touch the sensor, and then back down when I remove my hand) but none of the LEDs get activated.

Alternatively, if I set the system to run and touch the TMP36 so that it spikes up and registers temperatures around 70 C, and THEN pull out the LEDs one by one, I see the temperature sensor drop back down 10-20 degrees at a time until it's back in the normal range.

Could there by an ungrounded signal or something causing some interference? Would another resistor connected somehow to the temperature sensor pull down any stray voltage?

Thanks man! It really helped me. Moved the ground connection for the TMP36 to the other side of the board and voilà! They should advice that on the starter manual, it was driving me crazy.

It shows me that the sensor value is , degrees C: -15.82 sensor Value: 72 , Volts: 0.35 , degrees C: -14.84 sensor Value: 72 , Volts: 0.35 , degrees C: -14.84 sensor Value: 71 , Volts: 0.35 , degrees C: -15.33 sensor Value: 68 , Volts: 0.33 , degrees C: -16.80 sensor Value: 68 , Volts: 0.33

and then the voltage is incorrect and the themperature i have the same code as arduino website

Thanks!