2 wire temperature sensor

Hi everyone,

I’m trying to figure out how to interact with a basic (?) 2 wire temperature sensor from an alarm clock.
I still have to take it out, i was trying to figure out a way to pull it out without cutting the wires and keep the little plug but i think i’m going to have to do so.

I’ve seen a lotta tutorials regarding 3 wire sensors, with the corresponding library, but i couldn’t find any 2 wire sensor tutorials, nor any library for them. Are they the same? I was thinking of maybe just plugin the sensor to the arduino analog pins and try to read some data, but i haven’t done so yet. Should I? How to get the temperature from such a sensor? It doesn’t seem very uncommon.

Thanks in advance for your help.

Thermistor? Try this tutorial.

Hey thanks for your help, seems to be headed in the right direction.
However i only have a 1K resistance is that a problem? I tried the tutorial with it and it doesn’t seem to work.

Do yo have 10 x 1k resistors? If so put them in series for 10k, might be a bit messy on the breadboard but will do the job. **Have a multimeter? Test the resistance of the sensor.

If you have a multimeter, check that the sensor is indeed a thermistor (it might not be). Measure its resistance and check that the resistance changes when you heat or cool the sensor.

For best results, you would normally use a companion resistor (10K in the tutorial) that has about the same resistance as the sensor in the middle of the expected temperature range.

All right i’ll try with 10 1K resistances, though it’s only 18.6°C in my room so is that still 10K? Unfortunately i do not have a multimeter, still have to buy one.

EDIT: I did try, the Thermistor resistance does decrease when i heat up the sensor, and increases when i cool it down, when i use this sketch:

Copy Code

    // the value of the 'other' resistor
    #define SERIESRESISTOR 10000
    // What pin to connect the sensor to
    #define THERMISTORPIN A0
    void setup(void) {
    Serial.begin(9600);
    }
    void loop(void) {
    float reading;
    reading = analogRead(THERMISTORPIN);
    Serial.print("Analog reading ");
    Serial.println(reading);
    // convert the value to resistance
    reading = (1023 / reading) - 1;
    reading = SERIESRESISTOR / reading;
    Serial.print("Thermistor resistance ");
    Serial.println(reading);
    delay(1000);
    }

However, with the following, the temperature is always -273.15 degrees, it doesn’t seem to work. How is that?

    // which analog pin to connect
    #define THERMISTORPIN A0
    // resistance at 25 degrees C
    #define THERMISTORNOMINAL 10000
    // temp. for nominal resistance (almost always 25 C)
    #define TEMPERATURENOMINAL 25
    // how many samples to take and average, more takes longer
    // but is more 'smooth'
    #define NUMSAMPLES 5
    // The beta coefficient of the thermistor (usually 3000-4000)
    #define BCOEFFICIENT 3950
    // the value of the 'other' resistor
    #define SERIESRESISTOR 10000
    int samples[NUMSAMPLES];
    void setup(void) {
    Serial.begin(9600);
    analogReference(EXTERNAL);
    }
    void loop(void) {
    uint8_t i;
    float average;
    // take N samples in a row, with a slight delay
    for (i=0; i< NUMSAMPLES; i++) {
    samples[i] = analogRead(THERMISTORPIN);
    delay(10);
    }
    // average all the samples out
    average = 0;
    for (i=0; i< NUMSAMPLES; i++) {
    average += samples[i];
    }
    average /= NUMSAMPLES;
    Serial.print("Average analog reading ");
    Serial.println(average);
    // convert the value to resistance
    average = 1023 / average - 1;
    average = SERIESRESISTOR / average;
    Serial.print("Thermistor resistance ");
    Serial.println(average);
    float steinhart;
    steinhart = average / THERMISTORNOMINAL; // (R/Ro)
    steinhart = log(steinhart); // ln(R/Ro)
    steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
    steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
    steinhart = 1.0 / steinhart; // Invert
    steinhart -= 273.15; // convert to C
    Serial.print("Temperature ");
    Serial.print(steinhart);
    Serial.println(" *C");
    delay(1000);
    }

EDIT: code

EDIT: ok i figured the issue is probably due to the average method. When I don’t get an average based on 5 picks, it works fine, at least the result doesn’t seem absurd. So I’ll try to figure out this average issue.

The "one wire" temperature sensors actually use 2 wires. One of them is ground.

What resistance did you measure for the thermistor?

Be aware that if you want reasonable accuracy, the nonlinear Steinhardt correction that you are using to calculate the temperature has coefficients that need to be "tuned" for each type of thermistor. http://playground.arduino.cc/ComponentLib/Thermistor2