Temperature sensor conversion

I’ve put enough time into this and would love some fresh eyes on this.
I’ve got a Grove IoT Starter Kit connected to my Core, and it has a v1.1 Temperature sensor (Thermistor model NCP18WF104F03RC)
I haven’t been able to find the proper conversion of the analog reading (which is about 3200 at room temperature, higher when the temperature is higher) to a temperature.
The code samples I’ve tried usually expect a value of 1023 or less and convert to resistance accordingly, so I’m stumped.

Here’s my site with the temperature currently showing the analog value rather than temperature.


hahaha the hamster wheel is awesome!

The readings from the particle devices will go from 0-4095 instead of the arduino’s 0-1023. thats the extra resolution (extra bits) on the analog to digital converter. the calculation for resistance takes that into account, so try changing it and see how you go.

Thanks! I tried changing the value to that, but it’s not fitting properly. That solves half my issue, I think. I’ve noticed that a a colder temperature relates to a lower analog value.

Here’s my code

void updateTemperature(){
    resistance=(float)(4095.0-analogvalue)*10000/analogvalue; //get the resistance of the sensor;
    temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;//convert to temperature via datasheet ;
    tempC =     (int)temperature;

Maybe see if this works for you:


I’ve wrapped that code in a small library at https://github.com/wgbartley/spark-thermistor-library. You can also find it in the web IDE by searching for “thermistor”. It should be the top result in that search.

I tried out the example library, and now it’s the same result as what I currently have. The temp in C is between 49 and 51, which I believe is incorrect, since there is currently a hamster thriving in that spot. I am happy to report that heating the thermometer with my thumb does increase the temp, so that part’s correct.

The hamster tracker is cool :hamster: