Pages: [1]   Go Down
Author Topic: Temp sensor dramatic changes  (Read 743 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

My background is in software but I'm really beginning to love the world of electronics, always a great feeling to put your knowledge to create something physical rather than abstract smiley-grin

Now the question. After going through some beginner tutorials on Massimo's youtube channel I acquired a temperature sensor in order to test it out. It seems to work (I think) though the value stay around 20-25 on their own accord, not changing when I hold it or anything which is very strange. However when I hold it up next to my laptop's fan that's spewing out hot air it then changes - so I guess it is working.

I then tried to plug in some LEDs in order to have a sort of a visual explanation for the temperature where more and more LEDs flash the higher the temperature goes above a base level. The problem I have however is it often goes from 20ish to near 30 in less than a second, and these leaps seem to be fueled by the weirdest thing - opening/closing the Terminal on my computer.

Is this something to do with Arduino's electronic output limit or something of that type, or is it more likely to be a setup issue by me.
Logged

Offline Offline
Edison Member
*
Karma: 57
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could you read this, http://arduino.cc/forum/index.php/topic,148850.0.html

You see, we need to know almost everything. Which Arduino board, which sensor, how is it connected, what is your sketch, what do you use as power supply, do you use a breadboard ?
You can copy/paste your sketch in your post between the [code] ... [/code] tags.

If you mention something, like Massimo's youtube channel, please provide a link to it.
Is it this one, http://www.youtube.com/user/rswwwchannel ?
« Last Edit: April 01, 2013, 03:04:19 am by Erdin » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Fair point.

Here's some more info;

Code
Code:
const int sensorPin = A0;
int sensorVal;
float voltage;
float temperature;
int baseTemp = 20;

void setup(){
  Serial.begin(9600);
  
  for (int x=11; x<14; x++) {
    pinMode(x, OUTPUT);
    digitalWrite(x, LOW);
  }
  
}

void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor value: ");
  Serial.print(sensorVal);
  voltage = (sensorVal/1024.0) * 5.0;
  Serial.print(", Volts: ");
  Serial.print(voltage);
  temperature = (voltage - .5) * 100;
  Serial.print(", Temperature (degrees): ");
  Serial.println(temperature);
  
  if (temperature > baseTemp+3) {
     digitalWrite(11, HIGH);
     digitalWrite(12, HIGH);
     digitalWrite(13, HIGH);
  } else if (temperature > baseTemp+2) {
     digitalWrite(11, HIGH);
     digitalWrite(12, HIGH);
     digitalWrite(13, LOW);
  } else if (temperature > baseTemp+1){
     digitalWrite(11, HIGH);
     digitalWrite(12, LOW);
     digitalWrite(13, LOW);
  }
  
  delay(250);
}

Board configuration in attachment:
From the wires joining to the sensor, the orange links to 5v, white links to A0 and blue to GND.

In the rest of the configuration the red, white, and black from LEDs link to 11, 12, and 13 respectively. The blues all link back to GND.

Result
The result that is given often sticks around somewhere between 20 - 25 and the LED's are turned on or off based on the code logic. But often times e.g. if the lights are all off and the terminal is opened within about a second the degrees C jump from 20 or so to 30. Alternatively if all the lights are on and the terminal is opened the degrees jump from 30 or so back to around 20. Both of these scenarios appear to happen randomly but quite often.

The video
The youtube video I watched was this


Compared to the quality of the rest of the videos, Massimo didn't explain this one in as much detail - so I simply used this video to get a hint as to how this temperature sensor works and tried to tie up the configuration myself.

Also I'm not sure if my temperature sensor even works or is just not sensitive. When I hold it it seems to either stay at wher it is or deviate very slowly by one degree (or less) lower. Which is quite weird as i'm sure I'm not colder than room temperature smiley-grin


* IMAG0091.jpg (719.6 KB, 3264x1840 - viewed 17 times.)
« Last Edit: April 01, 2013, 11:32:20 am by mrxyz » Logged

Offline Offline
Edison Member
*
Karma: 57
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I assume you have a Arduino Uno and a LM35 or TMP36 temperature sensor.
Adafruit has a good tutorial for those temperature sensors, http://learn.adafruit.com/tmp36-temperature-sensor

Does the breadboard make good contact ? What happens if you wiggle the wires and the sensor ?
Is the Arduino powered with the USB ? Do you have a multimeter to measure the 5V ? Or perhaps you could try a power supply. To get a good temperature, the voltage must be 5.0V. Not for the sensor, but for the analog input of the Arduino.

Opening the serial monitor resets the Arduino board. Why that changes the temperature, I don't know.

In your sketch, there is some weird things going on between 'int' and 'float'.
Could you change baseTemp into this:
Code:
float baseTemp = 20.0;

To get the most accurate temperature, you could add 100nF to the +5V and GND, next to the sensor. You could also use the average of about 5 or 100 analogRead() values. But to do that, you have to create a function first, for example getTemperature().

If you have this working, take a look at a digital sensor, DS18B20. With that sensor, all the analog troubles are gone.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I assume you have a Arduino Uno and a LM35 or TMP36 temperature sensor.
Adafruit has a good tutorial for those temperature sensors, http://learn.adafruit.com/tmp36-temperature-sensor

Does the breadboard make good contact ? What happens if you wiggle the wires and the sensor ?
Is the Arduino powered with the USB ? Do you have a multimeter to measure the 5V ? Or perhaps you could try a power supply. To get a good temperature, the voltage must be 5.0V. Not for the sensor, but for the analog input of the Arduino.

Opening the serial monitor resets the Arduino board. Why that changes the temperature, I don't know.

In your sketch, there is some weird things going on between 'int' and 'float'.
Could you change baseTemp into this:
Code:
float baseTemp = 20.0;

To get the most accurate temperature, you could add 100nF to the +5V and GND, next to the sensor. You could also use the average of about 5 or 100 analogRead() values. But to do that, you have to create a function first, for example getTemperature().

If you have this working, take a look at a digital sensor, DS18B20. With that sensor, all the analog troubles are gone.

Yes the arduino is powered by the USB, just had another look and it seems the more LEDs that are being powered the higher the degrees that are printed out, and more LEDs are lit up. Also, I have no idea what a multimeter is, was just trying to play around with sensors as well as analog inputs to get the hang of it.

In the meantime I'll try some other stuff from the tutorial link you've posted.
Logged

Offline Offline
Edison Member
*
Karma: 57
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A multimeter is a voltage/current/ohm-meter.
http://en.wikipedia.org/wiki/Multimeter

The USB power is too weak for your circuit.
So you need a power supply of 6..12V.

If the voltage drops, the Arduino 'thinks' that the temperature rises.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh really, ok I will invest in one soon then.

Also - my temperature sensor seems to be completely inadequate even after following a non-LEDed example (top example on http://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor). Now I'm not sure how efficient this sensor can be but it really does not seem to change at all upon me holding it. Human body temperature being 37 degrees, it should at least rise slightly from the 20-25 degrees it stays at. Even after storing it in a freezer for 20 mins it doesn't change the temperature at all seemingly. Though there are always fluctuations it stays within a 5 degrees range going from 20 - 25 (very rarely out of this range). One thing I did do however when setting up the board was I had plugged the sensor the other way around so 5v and GND were connected to the opposite ends than they were supposed to be. Perhaps it is damaged?

Another thing, I receieved this sensor with a bunch of other things inside a small plastic bag. I have no idea if it actually is a temperature sensor but looks exactly like it. It also bears no markings. All arduino sensors don't look the same do they?
Logged

Offline Offline
Edison Member
*
Karma: 57
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The LM35/TMP36 surely would change with changing temperature.
Keeping it in the fridge would immediately drop the temperature reading.

It is broken, or it is not a temperature sensor.
The temperature sensors have something written on them. With a magnifier you should be able to read something.

If it is with shiny plastic, then it is a IR transmiter or receiver.

If nothing is written on it, perhaps it is a normal transistor.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The LM35/TMP36 surely would change with changing temperature.
Keeping it in the fridge would immediately drop the temperature reading.

It is broken, or it is not a temperature sensor.
The temperature sensors have something written on them. With a magnifier you should be able to read something.

If it is with shiny plastic, then it is a IR transmiter or receiver.

If nothing is written on it, perhaps it is a normal transistor.

How do I find out which of the two above is happening in this case?

As for the sensor it has very little written on it indicating anything. At the back it reads 'J Z' and the front under a bubble-like sensor bit it says 1744s. It's a shame how every online resource of the two types of temperature sensors contains an image of the back. I've added an image of the front facing side (though it's a little blurry), there is basically a bubble-like round area which sticks out. That's all the information I can give about this sensor. Any ideas?


* IMAG0093.jpg (716.96 KB, 1840x3264 - viewed 12 times.)
« Last Edit: April 01, 2013, 04:27:18 pm by mrxyz » Logged

Offline Offline
Edison Member
*
Karma: 57
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm for 99% certain it is a IR (infrared) receiver.
I might be blown, singe the pin usage is: Vout, GND, +Vcc (looking at the bubble with first on left).

This one looks just like it, http://www.p-wholesale.com/cn-pro/5/114to1/infrared-receiver-led-module-79339.html
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That is exactly what it is. Haha definitely explains why it wasn't measuring temperature.

Will have to be more careful with sensors in the future.
Logged

Pages: [1]   Go Up
Jump to: