[S]Convert analog output from an unknown temperature sensor to celsius degrees?

Hi everyone, i need convert the analog output from an analog temprature sensor with a LM393 comparator and a MF52 thermistor, to celcius degrees, http://i.ebayimg.com/00/s/NTc2WDcwMw==/z/L0oAAOSw7I5TsR~b/$_35.JPG here is a link to a picture of the sensor, i don't have a datasheet of this sensor, but i know this sensor works with an VCC input of 5 volts, searching a little, i finded two tables with a values in ohm, i will attach that information, i hope someone can help me, sorry for my bad redaction, i don't speak english.

Try this:

http://playground.arduino.cc/ComponentLib/Thermistor2

The 10k resistor is most likely already monted on that board.
Leo..

Wawa:
Try this:

Arduino Playground - HomePage

The 10k resistor is most likely already monted on that board.
Leo..

Thanks, but this doesn't work, in the schema the guy used a 10k resistor, but i only have the sensor module connected directly to Arduino, me just need the way to convert the analog output from this sensor to celsius degrees, in that post the guy used a thermistor directly, but i have a sensor module with a LM393 comparator, not just the thermistor, any idea?

If you have access to the analogue output of the sensor, you still need to calibrate it against known temperature unless it is a known output type that gives a known voltage change per degree.

Weedpharma

weedpharma:
If you have access to the analogue output of the sensor, you still need to calibrate it against known temperature unless it is a known output type that gives a known voltage change per degree.

Weedpharma

The voltage change per degree could be calculated with the datasheet of the thermistor?

The sensor you have has a digital output. That can/must be connected to a digital input.
It acts like a thermostat. ON/OFF only. Switchpoint (temp) is set with the blue 10-turn pot.

But the sensor also has an analogue output.

That can be used to MEASURE the temperature if you connect it to an analogue input.
With one of the sketches on that page I linked to.
Don't add a 10k resistor as explained on that page, because there is already one on your sensor board.
Leo..

Thanks, but this doesn't work, in the schema the guy used a 10k resistor, but i only have the sensor module connected directly to Arduino, me just need the way to convert the analog output from this sensor to celsius degrees, in that post the guy used a thermistor directly, but i have a sensor module with a LM393 comparator, not just the thermistor, any idea?

The 10k resistor is most likely already mounted on that board.

I agree with @wawa. The analog output from the 4pin module is from the point between a 10K resistor and the MF52 NTC thermistor in any schematic for the LM 393 thermistor modules I have seen.

The code in Thermistor2 which was referenced in reply #1 should work. Did you try it? What was the result?
Post the code you try, and any output if you are not successful.

/*
   Inputs ADC Value from Thermistor and outputs Temperature in Celsius
    requires: include <math.h>
   Utilizes the Steinhart-Hart Thermistor Equation:
      Temperature in Kelvin = 1 / {A + B[ln(R)] + C[ln(R)]3}
      where A = 0.001129148, B = 0.000234125 and C = 8.76741E-08

   These coefficients seem to work fairly universally, which is a bit of a
   surprise.

   Schematic:
     [Ground] -- [10k-pad-resistor] -- | -- [thermistor] --[Vcc (5 or 3.3v)]
                                                 |
                                            Analog Pin 0

   In case it isn't obvious (as it wasn't to me until I thought about it), the analog ports
   measure the voltage between 0v -> Vcc which for an Arduino is a nominal 5v, but for (say)
   a JeeNode, is a nominal 3.3v.

   The resistance calculation uses the ratio of the two resistors, so the voltage
   specified above is really only required for the debugging that is commented out below

   Resistance = PadResistor * (1024/ADC -1)

   I have used this successfully with some CH Pipe Sensors (http://www.atcsemitec.co.uk/pdfdocs/ch.pdf)
   which be obtained from http://www.rapidonline.co.uk.

*/

#include <math.h>

#define ThermistorPIN A0                 // Analog Pin 0

float vcc = 4.91;                       // only used for display purposes, if used
// set to the measured Vcc.
float pad = 9850;                       // balance/pad resistor value, set this to
// the measured resistance of your pad resistor
float thermr = 10000;                   // thermistor nominal resistance

float Thermistor(int RawADC) {
  long Resistance;
  float Temp;  // Dual-Purpose variable to save space.

  Resistance = pad * ((1024.0 / RawADC) - 1);
  Temp = log(Resistance); // Saving the Log(resistance) so not to calculate  it 4 times later
  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
  Temp = Temp - 273.15;  // Convert Kelvin to Celsius

  // BEGIN- Remove these lines for the function not to display anything
  //Serial.print("ADC: ");
  //Serial.print(RawADC);
  //Serial.print("/1024");                           // Print out RAW ADC Number
  //Serial.print(", vcc: ");
  //Serial.print(vcc,2);
  //Serial.print(", pad: ");
  //Serial.print(pad/1000,3);
  //Serial.print(" Kohms, Volts: ");
  //Serial.print(((RawADC*vcc)/1024.0),3);
  //Serial.print(", Resistance: ");
  //Serial.print(Resistance);
  //Serial.print(" ohms, ");
  // END- Remove these lines for the function not to display anything

  // Uncomment this line for the function to return Fahrenheit instead.
  //temp = (Temp * 9.0)/ 5.0 + 32.0;                  // Convert to Fahrenheit
  return Temp;                                      // Return the Temperature
}

void setup() {
  pinMode(6, OUTPUT);
  digitalWrite(6, HIGH);
  pinMode(7, OUTPUT);
  digitalWrite(7, LOW);
  Serial.begin(9600);
}

void loop() {
  float temp;
  temp = Thermistor(1023 - analogRead(ThermistorPIN));     // read ADC and  convert it to Celsius
  Serial.print("Celsius: ");
  Serial.print(temp, 2);                            // display Celsius
  //temp = (temp * 9.0)/ 5.0 + 32.0;                  // converts to  Fahrenheit
  //Serial.print(", Fahrenheit: ");
  //Serial.print(temp,1);                             // display  Fahrenheit
  Serial.println("");
  delay(1000);                                      // Delay a bit...
}

The problem was the output voltage is going down when the temperature is going up, but i fixed it subtracting the analog input to 1023, thank you guys.

Because your sensor is an NTC (Negative temperature coeficient).
Use Googe to learn about NTC termistors.

Another good link to learn about NTC termistors

I think it was because the code expected the thermistor connected to 5volt and the 10k resistor to ground.
The breakout board might have had the resistor to 5volt and the thermistor to ground.
Swapping A/D 0 and 1023 in code will fix that.
The non-linearity you talk about is taken care of with the Steinhart-Hart thermistor equation.
Leo..

Sorry, i misunderstood your previous questions.
Swap this line

temp = Thermistor(1023 - analogRead(ThermistorPIN));

to

temp = Thermistor(analogRead(ThermistorPIN));