In order to programmatically measure temperature, you would use some form of temperature sensor. However, you would have to choose between analog and digital temperature sensors.
The voltage across analog temperature sensors changes with temperature. This means that in order to use an analog temperature sensor with a microcontroller or other digital device, you would need an analog-to-digital converter (ADC).
Analog-to-digital converters convert a voltage reading to a digital representation that can be used by a digital device such as a microcontroller or single-board computer (Raspberry Pi, Beaglebone, Latte Panda, among others).
One common example of an analog temperature sensor is the thermistor. A thermistor changes its resistance in accordance with its temperature. There are two types of thermistors: Positive Temperature Coefficient (PTC) and Negative Temperature Coefficient (NTC).
Positive temperature coefficient thermistors increase their resistance if their temperature increases. Negative temperature coefficient thermistors decrease their voltage as temperature increases.
Digital temperature sensors are usually packaged devices containing an analog temperature sensor such as a thermistor and an analog-to-digital converter to convert the voltage reading to a digital representation that can be sent to a microcontroller via an i2C or similar communication interface.
Digital temperature sensors are more convenient than analog ones due to the fact that you don’t have to convert the analog to digital converter’s output yourself. It will instead provide you with a temperature reading in degrees.
Thermistors do have a cost advantage if you use them with your microcontroller’s built-in ADC. Thermistors are significantly cheaper than digital temperature sensors.
