Pages: [1] 2   Go Down
Author Topic: Temperature readings  (Read 1580 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 37
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm having a little trouble hooking up my 10k themistor and resistor to my UNO, but I think i got it.  I am trying to sense the ambient temperature.  I am using a code that i used in a LilyPad project, so i know the code works.  However, when i run the code with my UNO, this is what I get:

Temp reading = 1023 - 3.30 volts
279.68 degress C
535.42 degress F

Anyone have any advice?
Thanks
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Assuming 1023 is the analog reading you are getting from the A/D converter, looks like it is just reading 5V, and not doing any resister-divider kind of function.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 37
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How do i fix that?
I'm totally new to arduino!
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 75
Posts: 7303
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Since you are new, you need to provide your code and picture of your connections. That's typically needed for an answer. We don't have crystal balls.
Logged


Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26619
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe it is just a bit warmer than usual.

Maybe you could post your code and your circuit.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 227
Posts: 14007
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please post your code.

think you need to add conditional code, something like

#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)  // the 5 volt devices
  code for 5 Volt devices
#else
  code for 3.3Volt devices
#endif


Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 37
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, I need to start thinking!!
Sorry, i can't take a picture.  But here are my connections

I have my thermistor in gnd
i have my resistor in a different gnd
I have both of them in analog in (A0)

Here is my code:

Code:
/* Sensor test sketch
  for more information see http://www.ladyada.net/make/logshield/lighttemp.html
  */
 
#define aref_voltage 3.3         // we tie 3.3V to ARef and measure it with a multimeter!
 
 
 
 
//TMP36 Pin Variables
int tempPin = 1;        //the analog pin the TMP36's Vout (sense) pin is connected to
                        //the resolution is 10 mV / degree centigrade with a
                        //500 mV offset to allow for negative temperatures
int tempReading;        // the analog reading from the sensor
 
void setup(void) {
  // We'll send debugging information via the Serial monitor
  Serial.begin(9600);  
 
  // If you want to set the aref to something other than 5v
  analogReference(EXTERNAL);
}
 
 
void loop(void) {
 
  tempReading = analogRead(tempPin);  
 
  Serial.print("Temp reading = ");
  Serial.print(tempReading);     // the raw analog reading
 
  // converting that reading to voltage, which is based off the reference voltage
  float voltage = tempReading * aref_voltage;
  voltage /= 1024.0;
 
  // print out the voltage
  Serial.print(" - ");
  Serial.print(voltage); Serial.println(" volts");
 
  // now print out the temperature
  float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
                                               //to degrees ((volatge - 500mV) times 100)
  Serial.print(temperatureC); Serial.println(" degress C");
 
  // now convert to Fahrenheight
  float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
  Serial.print(temperatureF); Serial.println(" degress F");
 
  delay(1000);
}

 Thanks so much!
« Last Edit: June 20, 2011, 09:08:17 am by ABIA » Logged

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 227
Posts: 14007
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please modify your post, select the code and press # button --> looks so much better
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26619
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have my thermistor in gnd
i have my resistor in a different gnd
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Sydney Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There's a good write-up here:
http://www.arduino.cc/playground/ComponentLib/Thermistor2

This is my version, where the thermistor goes to ground and the pad resistor goes to positive.
sensorTempValue is already returned from analog read.

Code:

float calcTempValue; 

void calcTemperature()
{
  // utilizes the Steinhart-Hart Thermistor Equation
  // sample code from Arduino playground Thermistor2

  // this will have to be tested using resistors to simulate the thermistor
  // using values from CityCell's datasheet. (DONE 2011-05-26 AW)
  // As an example, typical values for a thermistor with a resistance of 3000 Ω at room temperature (25 °C = 298.15 K) are:

  //  a = 1.40 \times 10^{-3}

  //  b = 2.37 \times 10^{-4}

  //  c = 9.90 \times 10^{-8}

  // float thermR = 3000;            // nominal value of thermistor
  const float pad = 10000;               // value of pull-up resistor
  const float factorA = 1.4E-03;
  const float factorB = 2.37E-04;
  const float factorC = 9.90E-08;

  long resistance;
  float Temp;                      // a local temporary variable


  resistance = sensorTempValue * pad / (1024 - sensorTempValue);   // changed from sample code as our thermistor
  // goes to ground (NOT Vcc)                                                 
  // we use 1024  so an open cct thermister won't throw a divide-by-zero error                                                   

  Temp = log(resistance);
  Temp = 1 / (factorA + (factorB * Temp) + (factorC * Temp * Temp * Temp));
  calcTempValue = Temp - 273.15;            // convert Kelvin to Celsius


}  // end calcTemperature()


Amanda
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 75
Posts: 7303
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's my tutorial with real pictures:

http://liudr.wordpress.com/2011/02/10/measure-temperature/

The circuit shows that your "other ground" is supposed to be 5V.



The R_unknown is the thermistor and R_known is the 10Kohm resistor.

I think you used the wrong code. The code is for a TMP36 sensor, not a thermistor.
Logged


Central MN, USA
Offline Offline
Tesla Member
***
Karma: 75
Posts: 7303
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the loop(). You will need Serial.begin(9600); in setup()
Code:
  float resistance, voltage, r_fixed, T0, T, R0,B;
  T0 = 298.15;//initial temperature for calibration
  R0 = 10000;//initial resistance for calibration
  r_fixed = 10972;//known resistance
  B = 4050;//B for normalization
  Serial.println("Temperature");

  while(1)
  {
    voltage = analogRead(sensor_a)*5.0/1024;// Renormalizing from 0 to 5 volts.
    resistance = voltage*r_fixed/(5.00-voltage);//find unknown resistance
    T = 1/(log(resistance/r_fixed)/B+1/T0)-273.14;//find temperature from unknown ressistance
    Serial.println(T);
    delay(500);
  }

I have reconnected my thermistor according to liudr's blog.  However, no code i try is uploading, even codes that were working before!!

What do you mean by not uploading? What error message?
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 37
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, it is finally uploading again!! Here is the code i uploaded.  However, it still gives me insanely high readings.  What can i do???
BTW, i am on 9600 baud
Code:
/* Sensor test sketch
  
  */
 
#define aref_voltage 3.3         // we tie 3.3V to ARef and measure it with a multimeter!
 
 
 
 
//TMP36 Pin Variables
int tempPin = 1;        //the analog pin the TMP36's Vout (sense) pin is connected to
                        //the resolution is 10 mV / degree centigrade with a
                        //500 mV offset to allow for negative temperatures
int tempReading;        // the analog reading from the sensor
 
void setup(void) {
  // We'll send debugging information via the Serial monitor
  Serial.begin(9600);  
 
  // If you want to set the aref to something other than 5v
  analogReference(EXTERNAL);
}
 
 
void loop(void) {
 
  tempReading = analogRead(tempPin);  
 
  Serial.print("Temp reading = ");
  Serial.print(tempReading);     // the raw analog reading
 
  // converting that reading to voltage, which is based off the reference voltage
  float voltage = tempReading * aref_voltage;
  voltage /= 1024.0;
 
  // print out the voltage
  Serial.print(" - ");
  Serial.print(voltage); Serial.println(" volts");
 
  // now print out the temperature
  float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
                                               //to degrees ((volatge - 500mV) times 100)
  Serial.print(temperatureC); Serial.println(" degress C");
 
  // now convert to Fahrenheight
  float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
  Serial.print(temperatureF); Serial.println(" degress F");
 
  delay(1000);
}
 
 
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 75
Posts: 7303
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't think you read my replies very carefully. You are using the wrong code so re-read my replies and upload the right code.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 37
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got it working! I needed a different code and resistor.  I posted those details in Sensors under Arudino thermistor.
Thanks to all for their help!
« Last Edit: June 22, 2011, 10:20:59 am by ABIA » Logged

Pages: [1] 2   Go Up
Jump to: