Bosch fluid temp sensor

So I have shelved the idea of using a DS18B20 as packaging it up makes no sense - so to use a normal car temp sensor seems the most obvious choice.

So I found a Bosch 0 280 130 026 sitting in the bottom of a drawer - M12 thread seems perfect.

This is the datasheet, with resistance table for the range of temperature:

http://www.bosch-motorsport.de/pdf/sensors/temperature/NTC_M12.pdf

I get an analogRead value of 743 for 78c... and it goes to about 300 for room temperature.

This is with using a 1k resistor between the analog in and ground.

So it seems like I can get a good range of using this set up - and using the right maths I seem to be able to work it out the resistance - but how to use the table and convert it in to celcius?

((1000*5)/((analogIn/1024)*5))-1000

James

very messy, I think... but it seems to correlate with another thermometer I have...

int sensorPin = 0;    // select the input pin for the potentiometer
float sensorValue = 0;  // variable to store the value coming from the sensor

long lookupR[] = {
  45313, 26114, 15462, 9397, 5896, 3792, 2500, 1707, 1175, 834, 596, 436, 323, 243, 187, 144, 113, 89};
long lookupT[] = {
  -40, -30, -20, -10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130};

float findV(float analogIn) {
  return analogIn / 1024 * 5.0;
}

long findR(float analogIn) {
  float voltage = findV(analogIn);
  return 5000 / voltage - 1000;
}

long lookup(long R) {
  int x = 0;
  for (int i=0; i <= 17; i++){
  if (R < lookupR[i]) {
    x = i;
  }
  }
  return x;
}
     

void setup() {
  Serial.begin(9600);
}

void loop() {
  delay(1000);
  sensorValue = analogRead(sensorPin);    
  Serial.println(sensorValue);
  Serial.println(findR(sensorValue));
  Serial.println(map(findR(sensorValue),lookupR[lookup(findR(sensorValue))],lookupR[lookup(findR(sensorValue))+1],lookupT[lookup(findR(sensorValue))],lookupT[lookup(findR(sensorValue))+1]));  
}