Pages: [1]   Go Down
Author Topic: Arduino Thermistor  (Read 1503 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 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
Logged

UK
Offline Offline
God Member
*****
Karma: 13
Posts: 903
Twitter: @simonmonk2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

UK
Offline Offline
God Member
*****
Karma: 13
Posts: 903
Twitter: @simonmonk2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote

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.

Logged

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

UK
Offline Offline
God Member
*****
Karma: 13
Posts: 903
Twitter: @simonmonk2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

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

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:
// 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("----------------");
}
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3638
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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.
Logged

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

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!
Logged

UK
Offline Offline
God Member
*****
Karma: 13
Posts: 903
Twitter: @simonmonk2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Does the number go up when you put your finger on the Thermistor?
Logged

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

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

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

UK
Offline Offline
God Member
*****
Karma: 13
Posts: 903
Twitter: @simonmonk2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
Logged

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

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

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!!  smiley
Logged

Pages: [1]   Go Up
Jump to: