Measure negative temperature with Lm35

Summary of Measure negative temperature with Lm35


This project shows how to measure negative temperatures with an LM35 without a negative supply by using a circuit that offsets the sensor output. It includes a Proteus simulation file and Bascom-AVR code for an ATmega16 to read two ADC channels, compute their difference, scale it, and display temperature on a 16x2 LCD.

Parts used in the Measure negative temperature with Lm35:

  • LM35 temperature sensor
  • ATmega16 microcontroller
  • 16x2 LCD module
  • Resistors (for offset/gain circuit)
  • Operational amplifier(s) or comparator(s) (for offset generation)
  • Proteus simulation file (project schematic)
  • Power supply (positive only, no negative rail)
  • Connecting wires and breadboard or PCB

LM35 can measure temperatures from -55deg to 150deg and we need negative supply voltage for measuring this negative temperature.
This circuit eliminates the negative voltage power supply and this project can measure the negative temperature
Download the protesu file to simulate the project on your desktop
Measure negative temperature

Bascom Code

$regfile = "m16def.dat"
$crystal = 1000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.0 , Rs = Portd.1
Config Adc = Single , Prescaler = Auto , Reference = Internal
Deflcdchar 0 , 12 , 18 , 18 , 12 , 32 , 32 , 32 , 32
Deflcdchar 1 , 32 , 4 , 12 , 28 , 28 , 32 , 32 , 32
Deflcdchar 2 , 32 , 4 , 14 , 31 , 31 , 32 , 32 , 32
Deflcdchar 3 , 32 , 4 , 14 , 31 , 31 , 7 , 6 , 4
Deflcdchar 4 , 32 , 4 , 14 , 31 , 31 , 31 , 14 , 4
Deflcdchar 5 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32
Dim A As Word
Dim B As Word
Dim C As Single
Dim D As Byte
D = 1
Start Adc
Cursor Off
Cls
Locate 2 , 1
Lcd "avrprojects.info"
Do
A = Getadc(3)
B = Getadc(4)
C = A - B
C = C / 4
Locate 1 , 1
Lcd "Temp =" ; C ; Chr(0) ; "c   "
Locate 1 , 16
Lcd Chr(d)
Waitms 500
Incr D
If D > 6 Then D = 1
Loop
End

For more Detail: Measure negative temperature with Lm35

Quick Solutions to Questions related to Measure negative temperature with Lm35:

  • Can LM35 measure negative temperatures without a negative supply?
    Yes; the project uses a circuit that eliminates the need for a negative voltage power supply to measure negative temperatures with the LM35.
  • What microcontroller is used in the provided code?
    The Bascom code targets an ATmega16 microcontroller using m16def.dat and a 1 MHz crystal setting.
  • How is the temperature displayed?
    Temperature is displayed on a 16x2 LCD configured via PortD pins in the Bascom code.
  • Which ADC channels are read in the code?
    The code reads ADC channels 3 and 4 and computes their difference to obtain the sensor reading.
  • How is the temperature value calculated in the code?
    The code subtracts ADC channel 4 from channel 3, divides the result by 4, and displays that value as temperature in degrees Celsius.
  • Is a Proteus file available for simulation?
    Yes; the project includes a Proteus file for simulating the circuit on a desktop.
  • Does the project use internal ADC reference?
    Yes; the Bascom configuration sets the ADC reference to Internal.
  • What clock frequency is configured in the code?
    The code sets the crystal frequency to 1 MHz with $crystal = 1000000.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top