Trouble getting pt100 Celsius reading from spark analog pin

Having problems getting correct vallues from a PT100 thermal resistor.

Here is our setup:
5v -----> resistor------> Our spark line is here ------> PT100 ------> Ground

Power drains to ground through a resistor, with our analog spark pin we can detect how much power is drained.
This works and gives us an value to read,
however, not in celsius.

so far i know just about the values for the resistance:celsius from here
http://en.wikipedia.org/wiki/Resistance_thermometer.
there is a function which estimates it, i wanna calculate it!.

Found a calculator online
http://www.thermibel.be/documents/pt100/conv-rtd.xml?lang=en

What kind of resistor and math can we use to calculate the temperature?

Thanks in advance,
Erik

PS. ive been at this for 5 hours and tried several functions and examples from the internet, which all of them failed to give a proper reading.

most examples use something like


float temp2=(analogRead(A0)*5.0)/1024.0;
  temp=(temp2-0.5)*100;
or
  
 // float millivolts = (analogRead(A0) / 1024.0) * 5000;
   // float celsius = millivolts/10; // sensor output is 10mV per degree Celsius

Both does not give a proper celsius display.

The simplest (and most accurate) way to approach this is to calibrate the sensor.

First put the sensor in an ice+water bath - this will hold at 0° C. Record the value you get from analogRead(A0).

Then put the sensor in boiling water (assuming it can tolerate that) and again measure the value. This gives you two point calibration.

In your code, you then compute the temperature based on the offset and scale of the calibration points:

int zeroDeg = 123; // the analog value you measured at 0C
int hundredDeg = 789;  // the analog value you measured at 100C

int read = analogRead(A);   // the current temperature

float degreesC = ((analogRead-zeroDeg)*100.0)/(hundredDeg-zeroDeg);

Just in case you don’t know, PT100 sensors are normally read using a wheatstone bridge which helps cancel out the resistance of the wires, and changes in resistance of the external resistors due to temperature.

Wikipedia discusses this, as well as other sources of error. It also talks about the formula I used above in more detail.

Note that the spark uses a 12-bit ADC, so you change 1024.0 to 4096.0.