-
Notifications
You must be signed in to change notification settings - Fork 29
Temperature measurement with cheap NTC's
Thermistors Wiring Sample code SWAP packets
Thermistors provide a simple and inexpensive way to measure temperatures. They are resistors whose resistance change significantly with temperature. Compared with other solutions like the TP36 or LM35 IC's, thermistors are cheaper and more accurate. They can work at any voltage, they are very robust and can be simply powered from an output pin.
Among thermistors, NTC's (Negative Temperature Coeficient) are easier to use for temperature measurements whilst PTC's are mostly used in switching applications. The downside of thermistors is that they are not linear so look-up tables or more complex formulas have to be implemented in order to transform voltage (or resistance) into temperature readings. For this aplication we will apply the Steinhart–Hart equation wich will release us from having to create our own look-up table.
The simplest thermistors circuit consists of a thermistor and a series resistor. We are using the following parts in our example:
- 10 Kohm 1% thermistor
- 10 Kohm 1% series resistor
panStamp NRG includes SM0603 footprints for a NTC circuit on the bottom side. In case you are using a panStamp AVR or you don't feel comfortable with SMD soldering, external through-hole components can be used instead.
We provide a SWAP-compatible sample application called ntc for the pinout shown in the above picture. If you use any other I/O pins from your module then you will have to change the code accordingly in ntc.ino.
// Digital output used to power the thermistor circuit
#define NTC_POWER_PIN 10
// Analog pin used to read the NTC
#define NTC_PIN A1
This code is quite simple. It relies on our thermistor library and SWAP stack. If you don't want to dive into the code, simply grab the application into your panStamp and configure your desired transmission interval from SWAPdmt.
SWAP status packets transmitted by this application are very simple. Data payload simply consists of two bytes. temp.xml is the device definition file used for this application. In order to transform this 2-byte number into a readable temperature you have to apply the formulas defined in the units section of this XML file:
Celsius degrees: Temperature (ºC) = data x 0.1 - 50
Fahrenheit degrees: Temperature (ºF) = data x 0.18 - 58
Kelvin degrees: Temperature (ºK) = data x 0.1 + 223.15