George Nyarangi

Digital thermomter using a PIC microcontroller

I just finished working on a digital thermometer on 6/28/2009 and I am glad to say that it is fully functional with great accuracy let alone the resolution. If anything, its resolution is too high thus the device itself is overly sensitive to slight temperature changes. Like any other device, the temperature reading is subject to some error which is dependent on many other factors. Nevertheless, the error in the temperature is ±6.71K at its worst and that is in a 175 °F environment. The error in the temp reading increases in very low and very high temperatures. Note that the thermometer's range is -55 °F to 175 °F.

The thermistor that I used in this device is a KTY83/110 Series Silicon Temperature Sensor manufactured by NPX Semiconductors. This is a Positive Temperature Coefficient (PTC) thermistor which makes life a little less painful. According to the datasheet, this thermistor has virtually linear characteristics. The other good thing about it is that the datasheet provides a table that lists ambient temperatures at various corresponding resistances in the range that the thermistor operates. I took this data and plotted it and it was somewhat linear although not quite. This was going to be a problem because modeling the data with a linear curve would mean introducing errors albeit small. Therefore, I modeled the data using a second order polynomial which was a better fit, and I only did this for data points within a range that I thought was reasonable i.e 0 °F to 120 °F.

The rest was the fun stuff. The thermistor was hooked up in a voltage divider fashion and an analog to digital conversion (ADC) was performed on the output voltage.128 samples were collected at any given time and the resistance of the thermistor was calculated using their average. Why 128? So that the resistance calculated at any point in time would be the most accurate. Using this resistance and the polynomial model, the temperature was calculated avoiding floating point computations for the sake of speed. Yes SPEED! Samples were collected as fast as the PIC18F452 microcontroller would allow. All the code for this project was written in C.

The remaining part was trivial: multiplexing and displaying the results on a 3 digit 7-segment LED display. And that was it: A fully functional digital thermometer.

Downloads