Revised version of LM35 based digital temperature meter
This is a revised version of my LM35 based digital thermometer project that I posted last year. Although it is one of the simplest projects, it is very popular among newbies who are just starting to learn microcontrollers. There was a little flaw in the original project as pointed by some readers. I was using a 1.2 V reference for A/D conversion with PIC16F688 microcontroller. However, the PIC16F688 datasheet says Vref should be equal to or higher than 2.2 V to ensure 1 LSB accuracy of A/D conversion. Here, I am rewriting the same project but this time I am using a MCP1525 IC to generate a precise 2.5 V reference for A/D conversion. This will improve the accuracy of temperature measurements.
The LM35 series of analog temperature sensors are produced by National Semiconductor Corporation and are rated to operate over a -55 °C to 150 °C temperature range. These sensors do not require any external calibration. The output voltage is proportional to the temperature, and the temperature-to-voltage conversion factor is 10 mV per °C. The sensor does not have any DC offset output voltage (which means the output is 0V at 0 °C temperature) and therefore, a negative voltage source is required in order to measure temperatures below 0 °C. For simplicity, the setup shown here is made to measure temperatures above 0 °C only. The PIC16F688 microcontroller reads the analog output voltage from the sensor through one of its ADC channel and derives the temperature information out of it.
For the maximum temperature value of 150 °C, the output voltage of the sensor would be 150 x 10 mV = 1. 5 V. If we use Vref = 5.0 V (power supply voltage) for A/D conversion, the resolution would be poor as the input signal goes only up to 1.5 V. Besides, if the supply voltage is not stable, it won’t be a good idea to use it as Vref for A/D conversion. Using a lower and more stable Vref voltage can improve both the resolution and the accuracy of A/D measurements. However, the datasheet of PIC16F688 microcontroller recommends to use reference voltage above 2.2 V to ensure 1 LSB accuracy of A/D conversion. The MCP1525 IC from Microchip provides a precise output voltage of 2.5 V, which could serve this purpose. This device is also available in TO-92 package, and therefore, it can be wired on a breadboard too.
The revised circuit diagram of the project is shown below. All the connections remain the same, except the two diodes and a resistor in the original circuit are replaced by a MCP1525 device.
The whole setup of this project is shown below. For illustrative purpose, I am using the LCD display from my I/O board project here. Don’t get confused with all the LEDs and tact switches on the board, they should be disregarded. I am only using the LCD part of it.
With Vref = 2.5 V, the resolution of 10-bit A/D conversion would be 2.5/1024 ? 2.44 mV/count. Which means,
Resolution of temperature measurement = 2.44 mV/(10 mV/°C) = 0.244 °C
I/P analog voltage = 2.44 x 10-bit count (mV)
Measured temperature = I/P voltage (mV)/(10 mV/°C) = 2.44 x 10-bit count/10 (°C)
Or, T (°C) = 0.244 x 10-bit Count
Floating point math can be avoided in programming to simplify the arithmetic. The complete program (source and HEX files) written in mikroC Pro for PIC can be downloaded from the following link.
The following snapshot of the Project Edit window from mikroC editor shows the configuration bit setting for this project.
The LM61 sensor is more convenient to use for measuring negative temperatures. Unlike LM35 (which has zero DC offset), the LM61 sensor has a DC offset of 600 mV, which allows reading negative temperatures without the need for a negative supply.