Digital Thermometer using PIC Microcontroller and LM35 Temperature Sensor Circuit diagram

Figure 1: Digital Thermometer Circuit Diagram

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.
   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

Full-Range Centigrade Temperature Sensor LM35 Packages

More information can be found from the LM35 datasheet

 Circuit diagram

As shown on the circuit diagram on figure 1 above, it is very easy to interface the LM35 to a PIC, its output pin can be connected to any analog input of the PIC, the VS to +5 supply and the ground to ground. In this example, the LM35 is connected to Analog 0 (pin 2 of PIC18F2620).
VDD and VSS of the pic microcontroller is not shown in the circuit diagram. VDD should be connected to +5V and VSS to GND. The MCLR is disabled in software and an internal oscillator clock is selected so no need for external crystal. 
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.

You can watch the video below to learn how to build the circuit diagram.

Watch The Video Tutorial: Circuit Diagram


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.


If you are using XC8 v1.35, the Peripheral Libraries which include the LCD and other peripherals like ADC, SPI, I2C libraries are no longer included in the installation file as with previous versions. You can either write your own LCD library and use MPLAB code configurator to configure the other peripherals or the easiest is to download the Peripheral Libraries as a separate download and install them,. You can download them at microchip website under the MPLAB XC Compilers downloads tab. They are now called PIC18 Legacy Peripheral Libraries.

Download: PIC18 Legacy Peripheral Libraries

Configure ADC: 

Start Conversion:

Manipulate Results: 

Watch The Video Tutorial: MPLAB XC8 Code

 Full Code:

You can download the full project files (MPLAB XC8 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 Thermometer Header  

Download Digital Thermometer HEX 

Download Digital Thermometer Main C  

Download Digital Thermometer Proteus