PIC Temperature Sensing

With Watch Dog Timer

Use the PICs Watchdog Timer as a temperature sensor! Its frequency changes linearly over temperature, so it's possible to build a thermometer without external chip! See Microchip App Note AN720. They claim accuracy up to 1 degree Celsius.

Jinx's test of PIC WDT Temperature accuracy

With Thermistors

Thermistors are easy to use because you can read it as a capacitor charge time.

Show Thermister Tempature on LCD

Characterizing a thermistor with the Steinhart-Hart equation

With Dallas sensors

PIC Microcontroller based Dallas DS18S20 IO

Dallas DS1620 interface with floating point (full accuracy) conversion to plain text and USART RS232 xmit

PIC 16F876A based Temperature (DS1620) / Humidity (HS15p) Display (Hitachi LCD) by Jody Wisman

With other sensors

16F676 Thermometer using LM 35 by Edwin Tugano Jr.

LM335A Micro controller interfacing

Remote analog sensor electronics LM335A Temperature

Scaleing and Display

James Michael Newton says:

A common question is "How do I display the digital output of an A2D converter [fed by a temperature sensor] as a temperature reading?"

You will need to scale the A2D output by multiplying or dividing by some constant number and possibly adding or subtracting a value. See:
the constdivmul code generator for the multiplication or division by a constant and the math library for the addition and/or subtraction.

Start by just displaying the output raw as a hexadecimal number using code from the base conversion part of the math library measure some different temperatures and make note of the numbers displayed and use multiplication and division to make sure that the change is correct. E.g. if you measure 70 degrees and 80 degrees and the display is (hex) 01h and 29h (decimal 1 and 41; a difference of 40) then you need to divide by 4 to get a change of 10. Next you need to add (or maybe subtract) a value. In the example, you need to add 45h (decimal 69) to get a display of 70 to 80 degrees. Then after you get the scaling right, add in a binary to decimal conversion routine from the same page.

For additional accuracy, you should in some way linearize the output of what ever temperature sensor you are using if it is not a pre-calibrated unit. Measure the sensors' output at multiple temperature points over the range of expected operation and then build a table of resulting values to lookup actual measurements in.

The Steinhart-Hart equation can reduce the number of points that must be measured when using thermisters by accuratly estimating (characterizeing) any number of points based on only three actual measurements which are often provided by the manufacturer.

If you use a seven segment LED, you need to translate the decimal values into segment patterns. See: Using lookup tables to convert numbers to seven segment LED display patterns

See:

see also:

 

Archive: