Required Components
About the Temperature Sensor
Sometimes, a thermistor is used as a temperature sensor.While thermistors are inexpensive and easy to obtain, their conversion formula is complex.
In this tutorial, we will use a more expensive but simpler IC (LM61CIZ) with a straightforward calculation formula.
The LM61CIZ outputs 600mV when the temperature is 0°C.
This is to prevent the output voltage from becoming negative even when the temperature is negative.
The LM61CIZ has a change of 10mV per degree Celsius.
For +25°C: 600 + 250 = 850mV
For -25°C: 600 - 250 = 350mV
Also, this sensor can be used without using a voltage divider resistor, and can be used by simply connecting the power supply.
The power supply also supports a wide range of 2.7~10V, and the output voltage remains at 600mV at 0°C regardless of the power supply voltage.
Electronic Circuit
Circuit DiagramBreadboard Circuit
Program
Program to measure temperature
TEMP_ADC = 6
adc = ADC.new()
adc.ch(TEMP_ADC)
temp = 0
while true
adc.start
v = adc.read_v
adc.stop
temp = (v-0.6)*1000/10
puts("temp:" + temp.to_s)
end