Go Down

Topic: Arduino Thermistor (Read 1 time) previous topic - next topic

uink

I am new to arduino, though i have worked with lilypad.  I need to hook my arduino uno to a 10K thermistor, and don't know how.  Do i have to use a resistor? Where on the breadboard do i put the components?
Thanks

Si

You have to make the thermistor one half of a potential divider.

There is a thread here about the calculation, as thermistors are not linear devices.

http://arduino.cc/forum/index.php/topic,51364.0.html
--
My New Arduino Book: http://www.arduinobook.com

Si

Quote
http://www.arduinoevilgenius.com/projects


I'm guessing you have loaded the sketch for the temperature logger, rather than the thermostat.

If you read the sketch code, you have to send 'g' on the serial monitor to start the logging, then after a few mins 'r' to read the results back.

This sketch writes data to EEPROM and all sorts of clever stuff. You will probably want to sorten it, or at least change the logging period to something faster.

--
My New Arduino Book: http://www.arduinobook.com

Si

I don't think it will be the components.

Read through the sketch and fish out the bit with the formula, and then just use that in a simpler sketch of your own, that just takes a reading and then Serial.println(myReading) to see what's happening.

Have a go and post your sketch back.
--
My New Arduino Book: http://www.arduinobook.com

uink

I edited the code like you said (I think).  I am terrible with programming.  It still just prints 'ready' and stays.  I am using 9600 baud.  I tried other bauds, but the just print one line of characters and nothing more. 
Thanks

Code: [Select]
// Project 13 - Temperature Logger
#include <EEPROM.h>


#define ledPin 13
#define analogPin 0
#define maxReadings 255
#define beta 4090 // from your thermistors datasheet
#define resistance 33


void setup()
{
   pinMode(ledPin, OUTPUT);
   Serial.begin(9600);
   Serial.println("Ready");
}

void loop()
{
  if (Serial.available())
  {
    char ch = Serial.read();
    if (ch == 'g' || ch == 'G')
    {

    }   
    else if (ch == 'x' || ch == 'X')
    {

      EEPROM.write(0, 0);
      Serial.println("Data cleared");
    }
    else if (ch == 'r' || ch == 'R')
   
    {
      Serial.println("Mode set to deg C");

    }
    else if (ch == 'f' or ch == 'F')
    {
      Serial.println("Mode set to deg F");

    }
    else if (ch == '?')
    {
      reportStatus();
    }
  }

   delay(1000);
}



void logReading()
{

  {
    long a = analogRead(analogPin);
    float temp = beta / (log(((1025.0 * resistance / a) - 33.0) / 33.0) + (beta / 298.0)) - 273.0;


  }

  {
    Serial.println("Full! logging stopped");

  }
}

void reportStatus()
{
Serial.println("----------------");
Serial.println("Status");
Serial.print("Sample period\t");

Serial.print("Num readings\t");

Serial.print("Mode degrees\t");

Serial.println("----------------");
}

wildbill

As Si suspected, you're using code that's looking for characters sent from the serial monitor to tell it what to do. At this point you need (as he says) something more minimalist to check your wiring. Such as this:
Code: [Select]
#define analogPin 0
#define beta 4090 // from your thermistors datasheet
#define resistance 33

void setup()
{
Serial.begin(9600);
Serial.println("Ready");
}

void loop()
{
long a = analogRead(analogPin);
float temp = beta / (log(((1025.0 * resistance / a) - 33.0) / 33.0) + (beta / 298.0)) - 273.0;
Serial.println(temp);
delay(1000);
}


It wouldn't hurt to print out the value of 'a' too.

uink

I used wildbill's code, and now it is printing numbers!
It is printing 29.89; however i don't know what this number represents.  Where i am, it is currently 68F.   
Thank you!

Si

The calculation is for deg C. But its not that hot :)

Does the number go up when you put your finger on the Thermistor?
--
My New Arduino Book: http://www.arduinobook.com

uink

Yes, the numbers increase when i touch the thermistor. 

Si

Quote
Yes, the numbers increase when i touch the thermistor.


Excellent.

Your thermistor is 10k yes? and your series resistor 10k?

Do you have the data sheet for your thermistor, can you look up its 'Beta' value.

Change everywhere in the equation where is says 33 (my thermistor was 33k) to 10 and plug in your value of Beta at the top of the sketch and you should be there!

I.e.
Code: [Select]

float temp = beta / (log(((1025.0 * resistance / a) - 10.0) / 10.0) + (beta / 298.0)) - 273.0;


If you want to convert to deg F, F = C * 9 / 5 + 32
--
My New Arduino Book: http://www.arduinobook.com

uink

My thermistor is 10k. 
I switched all the 33 to 10. 
I'm using 3000 for my beta value. 
My resistor is 8.2 kiloOhms.

  And it is working! Thank you for all your help!!  :)

Go Up