Temperature Sensors: Vendor Number Weblink For The Part Description Unit Price
Temperature Sensors: Vendor Number Weblink For The Part Description Unit Price
There are several common types of temperature sensors, namely, semiconductor (silicon) type,
thermistors, resistive temperature devices, and thermal couples. The output signals of the sensors
can be in various formats such as analog voltage output, serial (SPI or IIC) output, or logic
output. A semiconductor type temperature sensor with analog voltage output will be discussed
in this subsection. The particular temperature sensor is LM34CZ. This is a temperature sensor for
general purpose applications.
This section shows how to connect the temperature sensor to the CSM-12C32 module and
provide the C-codes for initializing the on-chip analog-to-digital converter for capturing the
analog output voltage from the temperature sensor. Pictures, ordering information and web link
of the datasheet are shown below.
Part
Vendor Number Weblink for the part Description Unit Price
Precision temperature
Hobby
LM34CZ LM34CZ TEMP sensor: analog voltage $6.50
Engineering
output
A code snippet in C below can be used for initializing the ADC of the MCU to interface with the
LC34CZ. It is assumed that the analog voltage is fed to the channel 0 of the ADC module. Other
assumptions are included in the comment statements. The code snippet can be easily modified
for other conversion settings.
void initADC(void) {
Note that 10 bit resolution is recommended. Such resolution is 5 mV per bit. If a gain factor of 2
is used for amplifying the analog output voltage of the LM34CZ, the resolution for temperature
is 0.25 °F per bit. The resolution can be higher if the gain factor is larger.
A C function for reading the analog voltage is shown below. The delay for 1 ms in the function is
to give sufficient time for the ADC to finish the conversion. Every execution of this function will
result in a new temperature reading stored in the variable temperature.
void readTemp(void) {
short temperature;