Temperature Sensor -- Analog

In this exercise we'll see how to sense a temperature by purely analog means. My heart has always lain with analog, so there's something rather special about this.

The sensor is the National Semiconductors LM34DZ. This is a very cool part, and widely available. I got mine from All Electronics; it's not expensive, either. What makes it so neat is that it emits a voltage linearly proportional to the ambient temperature in Fahrenheit. We'll feed that voltage to the ADC within the PIC, scale it by some simple arithmetic and display the result on the LCD. It should be obvious that the source code calls upon the PMP built-in library unit for manipulating the LCD.

One scan of the schematic ought to convince you there's nothing to this, physically speaking:

The device is able to sense temperatures down to 0 degrees Fahrenheit, but apparently is capable of going even lower is you bias the ground pin (pin 3) into the negatives. I haven't tried this though. Perhaps a good read of the spec sheet might be in order for further experimentation in frigid climes:

The LM34DZ seems more than accurate enough for day-to-day situations. If you check out the photo above, you'll see an orange commercial unit above my circuit. The temperature shown in the commercial unit is 76.6 (its value is in the circle of the unit's display; don't get confused by the altitude reading in the large font). The LM34DZ chimes in at 77 degrees.

Take some time to look at my code. Note the rounding procedure I've used to get the value accurately to the nearest degree, just using ordinary whole number arithmetic. We don't need no stinking decimals!

There will be some other options for sensing temperature coming up in further exercises. In the meanwhile, this purely analog approach can't be beat for simplicity, either in the hardware or the software.

Click to get the source code.
Click to get the schematic PDF.

Next Project: Sound Sensor -- Digital

No comments:

Post a Comment