Plain and easy to use Library for the TI linear thermistors (TMP61, TMP63 and TMP64) using your own Analog Digital Converter (ADC).
The following are currently supported by the Library : TMP61, TMP63 and TMP64 (feel free to extend)
The TMP6x linear thermistors offer linearity and consistent sensitivity across temperature to enable simple and accurate methods for temperature conversion. The low power consumption and a small thermal mass of the device minimize the impact of self-heating.
Temperature ranging from -40°C to +125°C with 1% accuracy.
This Library is heavily inspired by the calculations provided by the TI datasheets. References at the bottom.
An quick and easy way to connect your Thermistor is to measure the resistance:
RBias should be picked according to your thermistor (e.g. for the TMP63 a 100K Ohm with 1% is a good pick).
Find more information or ideas on how to connect, please see the datasheet for recommendations.
-
Download and Add the source files to your project (Download the files, use the Arduino lib manager or Git Clone):
git clone https://github.com/SndrSchnklshk/TMP6x
-
Start using the Lib, include the following:
#include "TMP6x.h"
-
Construct an instance (e.g. 3.3V, 16-bit and max gain of 4.069V):
TMP61 tmp61 = TMP61(TMP6x_Voltages::V33, 16, 4.069);
-
Read the (analog) Thermistor pin
-
Read Integer Temperature with 1° degree precision:
tmp61.GetTemperature(yourAnalogValue);
-
Read Decimal Temperature with linear interpolation:
tmp61.GetInterpolatedTemperature(yourAnalogValue);
-
Enjoy some temperature and support me ;)
Example showing Arduino C code on how to use the library.
To use the class lib in STM32 in class C (e.g. Stm32CubeIDE) wrap the libary as follows:
Create a new Wrapper Header file (TMP6xWrapper.h):
#include
#ifdef __cplusplus
extern "C" {
#endif
void* TMP61_create();
void TMP61_release(void* obj);
float TMP61_temperature(void* obj, int adc);
#ifdef __cplusplus
}
#endif
Create a class file for the wrapper:
#include "TMP6xWrapper.h" //Whatever name you have picked for for the above header
#include "TMP6x.h"
/*extern "C"*/ void* TMP61_create() {
return new TMP61(TMP6x_Voltages::V33, 15, 6.144); //Just an example
}
void TMP61_release(void* obj) {
delete static_cast<TMP61*>(obj);
}
/*extern "C"*/ float TMP61_temperature(void* obj, int adc) {
return static_cast<TMP61*>(obj)->GetInterpolatedTemperature(adc);
}
Enjoy the lib, by calling:
void* tmp61Obj = TMP61_create();
temperature = TMP61_temperature(tmp61Obj, yourAdcValue);
//Arduino Example
#include "TMP6x.h" // Include the header
#define PIN_ADC 1 // Random ADC pin
TMP61 tmp61 = TMP61(TMP6x_Voltages::V33, 12); // 3.3V, 12-bit
void setup()
{
Serial.begin(115200); // Init the serial device
Serial.print("Ola! Feeling cool?"); // Welcome message
}
void loop()
{
int a = analogRead(PIN_ADC); // Read the analog value
float t = tmp61.GetInterpolatedTemperature(a); // Calculate the temperature
Serial.print("Temperature is "); // Begin printing output
Serial.print(t); // Print the Temperature
Serial.println("°C"); // Print the degrees plus a newline
delay(5000); // Wait 5 seconds
}
- Add internal buffer with some sophisticated averaging
- ... let me know!
TI Datasheet for more information (TMP61): Download PDF
TI Design Tool (Excel calculation): Download ZIP
The TMP6x Linear Thermistors are a products of Texas Instruments
Feel free to buy me beer ;)