Is it hot in here? This simple temperature measurement project gets you started with a low cost sensor. A thermistor is a resistor that changes its value based on temperature. These sensors are commonly used in rechargeable battery packs and are very accurate. Temperature range for the sensor is from -50C to 110C. You can record, display, graph and control a variety of heat or cold related devices, starting with weather, fish tank, egg incubator and of course a dog house heater!
The thermistor has a non-linear response, so math is used to obtained the correct reading. This can be a challenging part of using this sensor. This project is a step-by-step guide with the source code provided. How cool is that?
A 10 Kilohms resistor (Brown, Black, Orange, Gold)
A Semitec 103AT-2 Thermistor (sensor)
Wire the circuit as shown in the diagram. (Or make a permanent version with a proto cape.)
The sensor circuit is a simple voltage divider. A reference voltage of 1.8V (P9-32) is applied to the thermistor. This voltage is split proportionately between the sensor and a 10K resistor connected to ground (P9-34). The mid point will vary based on temperature, and is measured using the BeagleBone analog input. Increasing temperature reduces the resistance of the sensor. This results in a greater voltage at the input (P9-36).
First we request to use the bonescript library. Second we declare the pin we want to use AIN5 (P9_36).
Next we declare some variables we will need to calculate the temperature. “Ralpha” is calculated using a reference data point for the thermistor (from the datasheet). “B” is the material constant for the thermistor (from datasheet). “Ro” is the resistance of the thermistor (in ohms) at temperature To. “To” is the temperature which corresponds to the value of Ro (typically 25C). 25C equals 298 degrees Kelvin. The equation uses the exponential function (e^x) with the natural base “e”.
As part of the measurement, we need to convert the voltage we read on the analog pin AIN5 to a resistance value. Inside the function loop(), we first read the voltage on AIN5. From this voltage reading we can now calculate the corresponding resistance value. To do this, we take the voltage across the bias resistor (10 kilohms) and derive the current flowing in this resistor (I = V/R). Knowing the current flowing in the circuit, we can calculate the resistance of the thermistor (R=V/I). Where V = Vref – Vmeasured, the voltage present across the thermistor. Finally we can calculate the temperature from the resistance value of the thermistor.
Note: Math.log() computes the natural logarithm and all temperature values are in Kelvin (Kelvin = C + 273.15). We use the Math.round() to manage the number of digits being displayed. The result from the equation is in Kelvin, so we subtract 273.15 to obtain a Celsius value. To make everyone happy, a conversion to Fahrenheit. Finally we display all our results to the console.
Richard worked as the Senior Electrical Engineer at Logic Supply before relocating with his family in 2015. A general problem solver and well-known "Lab MacGyver", Richard is always on the lookout for creative approaches to design solutions and continues to explore new opportunities to build creative solutions to common challenges.