TI TMP006 Infrared Thermopile Sensor¶
Driver for the Texas Instruments TMP006 sensor.
The TI TMP006 (Infrared Thermopile Contactless Temperature Sensor) measures the temperature of an object without need of direct contact with the object. After initialization the sensor can be set active for periodic measurements. The conversion duration depends on oversample ratio. The oversample ratio can be determined by sensor initialization. The target object temperature can be calculated as follows: Temperature of sensor’s die (2 times right shifting and devide-by 32): Difference Temperature in Kelvin: Sensitivity of the thermopile sensor, with as calibration factor: Sensor’s voltage (the LSB size is ): Offset voltage: Seebeck coefficients of the thermopile: Temperature of the target object: Constants:
The calculation and constants are wrapped from TI TMP006 User’s Guide SBOU107.
This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.
-
TMP006_CONFIG_CR_AS1
¶ Conversion Time 0.25s, AVG Samples: 1.
1
(0x00)
-
TMP006_CONFIG_CR_AS2
¶ Conversion Time 0.5s, AVG Samples: 2.
1
(0x01)
-
TMP006_CONFIG_CR_AS4
¶ Conversion Time 1s, AVG Samples: 4.
1
(0x02)
-
TMP006_CONFIG_CR_AS8
¶ Conversion Time 2s, AVG Samples: 8.
1
(0x03)
-
TMP006_CONFIG_CR_AS16
¶ Conversion Time 4s, AVG Samples: 16.
1
(0x04)
-
TMP006_CONFIG_CR_DEF
¶ Default for Testing.
1
TMP006_CONFIG_CR_AS4
-
TMP006_CCONST_S0
¶ Calibration Factor.
1
(6.4E-14)
-
TMP006_CCONST_A1
¶ Constant .
1
(1.75E-3)
-
TMP006_CCONST_A2
¶ Constant .
1
(-1.678E-5)
-
TMP006_CCONST_TREF
¶ Constant .
1
(298.15)
-
TMP006_CCONST_B0
¶ Constant .
1
(-2.94E-5)
-
TMP006_CCONST_B1
¶ Constant .
1
(-5.7E-7)
-
TMP006_CCONST_B2
¶ Constant .
1
(4.63E-9)
-
TMP006_CCONST_C2
¶ Constant .
1
(13.4)
-
TMP006_CCONST_LSB_SIZE
¶ Sensor Voltage Register LSB Size.
1
(156.25E-9)
-
enum
@166
¶ - TMP006_OK
- Success, no error.
- TMP006_ERROR_BUS
- I2C bus error.
- TMP006_ERROR_DEV
- internal device error
- TMP006_ERROR_CONF
- invalid device configuration
- TMP006_ERROR
- general error
-
int
tmp006_init
(tmp006_t * dev, const tmp006_params_t * params)¶ Initialize the TMP006 sensor driver.
Parameters
dev: device descriptor of sensor to initialize params: configuration parameters Return values
- 0 on success
- -TMP006_ERROR_BUS on I2C bus error
- -TMP006_ERROR_DEV if sensor test failed
- -TMP006_ERROR_CONF if sensor configuration failed
-
int
tmp006_reset
(const tmp006_t * dev)¶ Reset the TMP006 sensor, afterwards it should be reinitialized.
Parameters
dev: device descriptor of sensor Return values
- 0 on success
- -1 on error
-
int
tmp006_set_active
(const tmp006_t * dev)¶ Set active mode, this enables periodic measurements.
Parameters
dev: device descriptor of sensor Return values
- 0 on success
- -1 on error
-
int
tmp006_set_standby
(const tmp006_t * dev)¶ Set standby mode.
Parameters
dev: device descriptor of sensor Return values
- 0 on success
- -1 on error
-
int
tmp006_read
(const tmp006_t * dev, int16_t * rawv, int16_t * rawt, uint8_t * drdy)¶ Read sensor’s data.
Parameters
dev: device descriptor of sensor rawv: object voltage value rawt: raw die temperature drdy: data ready, 0 if a conversion is in progress Return values
- 0 on success
- -1 on error
-
void
tmp006_convert
(int16_t rawv, int16_t rawt, float * tamb, float * tobj)¶ Convert raw sensor values to temperature.
Parameters
rawv: object voltage value rawt: raw die temperature value tamb: converted ambient temperature tobj: converted object temperature
-
int
tmp006_read_temperature
(const tmp006_t * dev, int16_t * ta, int16_t * to)¶ Convenience function to get ambient and object temperatures in [°C].
Note
Temperature scaled by x100 for accuracy and avoid floats
Parameters
dev: device descriptor of sensor ta: converted ambient temperature to: converted object temperature
-
TMP006_I2C_ADDRESS
¶ TMP006 Default Address.
1
(0x41)
-
TMP006_CONVERSION_TIME
¶ Default Conversion Time in us.
1
(1E6)
-
TMP006_USE_LOW_POWER
¶ Default low power mode.
1
(0)
If set to 0, the device will be always-on If set to 1, the device will be put in low power mode between measurements. This adds a
TMP006_CONVERSION_TIME
us delay to each measurement call for bringing the device out of standby.
-
TMP006_USE_RAW_VALUES
¶ Default raw value mode.
1
(0)
If set to 0, measurements will be converted to Celsius. If set to 1, raw adc readings will be returned.
-
struct
tmp006_params_t
¶ Parameters needed for device initialization.
-
i2c.h::i2c_t
i2c
¶ I2C device, the sensor is connected to.
-
uint8_t
addr
¶ the sensor’s slave address on the I2C bus
-
uint8_t
rate
¶ number of averaged samples
-
-
struct
tmp006_t
¶ Device descriptor for TMP006 sensors.
-
tmp006_params_t
p
¶ Configuration parameters.
-
tmp006_params_t