Watch the Video Tutorial part 1:

The LM35 series are precision integrated-circuit temperature sensors from Texas Instruments, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. Its output is linearly proportional to Centigrade temperature Scale and it changes by 10 mV per °C.
The LM35 thus has an advantage over linear temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. 
The LM35 does not require any external calibration or trimming to provide typical accuracy of ±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to +150°C temperature range. Low cost is assured by trimming and calibration at the wafer level. 
The LM35’s low output impedance, linear output, and precise inherent calibration make interfacing to readout or control circuitry especially easy. It can be used with single power supplies, or with plus and minus supplies. 
As it draws only 60 μA from its supply, it has very low self-heating, less than 0.1°C in still air.

The LM35 Temperature Sensor has Zero offset voltage, which means that the Output is 0V when the temperature is at 0 °C. Thus for the maximum temperature value (150 °C), the maximum output voltage of the sensor would be 150 * 10 mV = 1.5V.

If we use the supply voltage (5V) as the Vref+ for Analog to Digital Conversion (ADC) the resolution will be poor as the input voltage will goes only up to 1.5V and the power supply voltage variations may affects ADC output. So it is better to use a stable low voltage above 1.5 as Vref+. We should supply Negative voltage instead of GND to LM35 for measuring negative Temperatures.

Digital Thermometer using PIC Microcontroller and the LM35 Temperature Sensor

Features

  1. Calibrated directly in ° Celsius (Centigrade)
  2. Linear + 10.0 mV/°C scale factor
  3. 0.5°C accuracy guaranteed (at +25°C)
  4. Rated for full −55° to +150°C range
  5. Suitable for remote applications
  6. Low cost due to wafer-level trimming
  7. Operates from 4 to 30 volts
  8. Less than 60 μA current drain
  9. Low self-heating, 0.08°C in still air
  10. Non-linearity only ±1⁄4°C typical
  11. Low impedance output, 0.1 Ω for 1 mA load

Extract from the LM35 Datasheet

More information can be found from the LM35 datasheet

MikroC Code

A 16 x 2 lines LCD display is connected to PORT B. refer to the Interfacing LCD Display with PIC microcontroller article to learn more. PORTA is configured as a digital input. The analog data from LM35 digital sensor is connected to Analog 0 (RA0). To configure Analog to Digital converter is really easy, all we need is to configure the ADC, Start conversion and then manipulate the results. Refer to the article Analog to Digital Converter in PIC Microcontroller to learn more.

Watch the Video Tutorial part 2:

The circuit diagram of the project is shown on figure 1. At the beginning of the project, the LCD is is initialized, cleared, and the cursor is turned OFF. “StudentCompanion” is displayed on the first line of the LCD and “Thermometer” is displayed on the second line. After 1 second, the LCD is cleared and the main program starts in  an  endless  loop. The temperature is read from analog channel 0 (AN0 or RA0), converted into millivolts by multiplying with 5000, and dividing by the A/D converter resolution  (10 bits), and divided by 10 to get the temperature. The temperature is then converted into a string and is displayed on the LCD.

In this program, floating point arithmetic is used to find and display the temperature for higher accuracy.

You can download the full project files (MikroC Pro for PIC source code and Proteus Schematic design) below here.  All the files are zipped, you will need to unzip them (Download a free version of the Winzip utility to unzip files).  

Download Digital Themometer with MikroC

Download Digital Thermometer Proteus Shematic