Qwiic_TMP117_Py  packaging_test1-4-g0b53a4e
Python for SFE Qwiic TMP117
Loading...
Searching...
No Matches
qwiic_tmp117.QwiicTMP117 Class Reference
Inheritance diagram for qwiic_tmp117.QwiicTMP117:

Public Member Functions

def __init__ (self, address=None, i2c_driver=None)
 Constructor. More...
 
def is_connected (self)
 Determines if this device is connected. More...
 
def begin (self)
 Initializes this device with default parameters. More...
 
def get_address (self)
 Returns the I2C address of the device. More...
 
def read_temp_c (self)
 This function reads the temperature reading from the sensor and returns the value in degrees celsius. More...
 
def read_temp_f (self)
 This function calculates the fahrenheit reading from the celsius reading initially found. More...
 
def get_temperature_offset (self)
 This function reads the temperature offset value from the device. More...
 
def set_temperature_offset (self, offset)
 This function sets the temperature offset value on the device. More...
 
def get_low_limit (self)
 This function reads the low limit register that is set by the user. More...
 
def set_low_limit (self, lowLimit)
 This function allows the user to set the low limit register to whatever specified value, as long as in the range for the temperature sensor. More...
 
def get_high_limit (self)
 This function reads the high limit register that is set by the user. More...
 
def set_high_limit (self, highLimit)
 This function allows the user to set the high limit register to whatever specified value, as long as in the range for the temperature sensor. More...
 
def get_configuration_register (self)
 This function reads configuration register. More...
 
def get_high_low_alert (self)
 This function reads configuration register and saves the high and low alert flags. More...
 
def get_high_alert (self)
 This function reads the 15th bit of the configuration register to tell if the conversion result is higher than the high limit. More...
 
def get_low_alert (self)
 This function reads the 14th bit of the configuration register to tell if the conversion result is lower than the low limit. More...
 
def set_alert_function_mode (self, setAlertMode)
 This function sets the alert function mode to either "alert" or "therm" mode. More...
 
def get_alert_function_mode (self)
 This function gets the alert function mode to either "alert" or "therm" mode. More...
 
def soft_reset (self)
 This function performs a software reset, loading all the default values into the configuration register. More...
 
def set_continuous_conversion_mode (self)
 This function sets the conversion mode of the sensor to be continuous. More...
 
def set_shutdown_mode (self)
 This function sets the conversion mode of the sensor to be in shutdown mode. More...
 
def set_one_shot_mode (self)
 This function sets the conversion mode of the sensor to be in one shot mode. More...
 
def get_conversion_mode (self)
 This function reads the mode for the conversions. More...
 
def set_conversion_average_mode (self, convMode)
 This function sets the conversion averaging mode of the device when in Continuous Conversion Mode. More...
 
def get_conversion_average_mode (self)
 This function reads the conversion averaging mode. More...
 
def set_conversion_cycle_bit (self, conv)
 This function sets the conversion cycle time bit in Continuous Conversion mode. More...
 
def get_conversion_cycle_bit (self)
 This function returns the Conversion Cycle Bit value that the device is currently in at the time. More...
 
def data_ready (self)
 This function checks to see if there is data ready to be sent from the TMP117. More...
 
def read_register (self, register)
 Reads a register from the device. More...
 
def write_register (self, register, value)
 Writes a value to a register on the device. More...
 

Public Attributes

 address
 

Static Public Attributes

 device_name = _DEFAULT_NAME
 
 available_addresses = _AVAILABLE_I2C_ADDRESS
 
int kRegTempResult = 0x00
 
int kRegConfiguration = 0x01
 
int kRegTHighLimit = 0x02
 
int kRegTLowLimit = 0x03
 
int kRegEepromUl = 0x04
 
int kRegEeprom1 = 0x05
 
int kRegEeprom2 = 0x06
 
int kRegTempOffset = 0x07
 
int kRegEeprom3 = 0x08
 
int kRegDeviceId = 0x0F
 
int kConfigSoftResetShift = 1
 
int kConfigSoftResetMask = 0b1 << kConfigSoftResetShift
 
int kConfigDrAlertShift = 2
 
int kConfigDrAlertMask = 0b1 << kConfigDrAlertShift
 
int kConfigPolShift = 3
 
int kConfigPolMask = 0b1 << kConfigPolShift
 
int kConfigTNaShift = 4
 
int kConfigTNaMask = 0b1 << kConfigTNaShift
 
int kConfigAvgShift = 5
 
int kConfigAvgMask = 0b11 << kConfigAvgShift
 
int kConfigConvShift = 7
 
int kConfigConvMask = 0b111 << kConfigConvShift
 
int kConfigModShift = 10
 
int kConfigModMask = 0b11 << kConfigModShift
 
int kConfigEepromBusyShift = 12
 
int kConfigEepromBusyMask = 0b1 << kConfigEepromBusyShift
 
int kConfigDataReadyShift = 13
 
int kConfigDataReadyMask = 0b1 << kConfigDataReadyShift
 
int kConfigLowAlertShift = 14
 
int kConfigLowAlertMask = 0b1 << kConfigLowAlertShift
 
int kConfigHighAlertShift = 15
 
int kConfigHighAlertMask = 0b1 << kConfigHighAlertShift
 
int kConfigDeviceIdShift = 0
 
int kConfigDeviceIdMask = 0xFFF
 
int kConfigRevShift = 12
 
int kConfigRevMask = 0xF << kConfigRevShift
 
int kContinuousConversionMode = 0b00
 
int kOneShotMode = 0b11
 
int kShutdownMode = 0b01
 
int kThermMode = 1
 
int kAlertMode = 0
 
int kConvAvgNone = 0b00
 
int kConvAvg8 = 0b01
 
int kConvAvg32 = 0b10
 
int kConvAvg64 = 0b11
 
int kLowAlertIdx = 0
 
int kHighAlertIdx = 1
 
int kDeviceIdValue = 0x0117
 
float kTmp117Resolution = 0.0078125
 

Properties

 connected = property(is_connected)
 

Constructor & Destructor Documentation

◆ __init__()

def qwiic_tmp117.QwiicTMP117.__init__ (   self,
  address = None,
  i2c_driver = None 
)

Constructor.

Parameters
int,optionaladdress: The I2C address to use for the device If not provided, the default address is used
I2CDriver,optionali2c_driver: An existing i2c driver object If not provided, a driver object is created

Member Function Documentation

◆ begin()

def qwiic_tmp117.QwiicTMP117.begin (   self)

Initializes this device with default parameters.

Returns
bool Returns True if successful, otherwise False

◆ data_ready()

def qwiic_tmp117.QwiicTMP117.data_ready (   self)

This function checks to see if there is data ready to be sent from the TMP117.

Returns
bool True if the data is ready, otherwise False

◆ get_address()

def qwiic_tmp117.QwiicTMP117.get_address (   self)

Returns the I2C address of the device.

Returns
int The I2C address of the device

◆ get_alert_function_mode()

def qwiic_tmp117.QwiicTMP117.get_alert_function_mode (   self)

This function gets the alert function mode to either "alert" or "therm" mode.

Returns
int The alert mode

Allowable return values are: kThermMode kAlertMode

◆ get_configuration_register()

def qwiic_tmp117.QwiicTMP117.get_configuration_register (   self)

This function reads configuration register.

Use this function if you need to read certain flags before they are cleared. This can be found on page 25 of the datasheet.

Returns
int The configuration register value

◆ get_conversion_average_mode()

def qwiic_tmp117.QwiicTMP117.get_conversion_average_mode (   self)

This function reads the conversion averaging mode.

Returns
int The conversion averaging mode

Allowable return values are: kConvAvgNone kConvAvg8 kConvAvg32 kConvAvg64

◆ get_conversion_cycle_bit()

def qwiic_tmp117.QwiicTMP117.get_conversion_cycle_bit (   self)

This function returns the Conversion Cycle Bit value that the device is currently in at the time.

This bit can help determine the conversion cycle time that the device is in while being in continuous conversion mode. (See table in set_conversion_cycle_bit, or page 27 of datasheet)

Returns
int The conversion cycle bit value

Allowable return values are 0-7

◆ get_conversion_mode()

def qwiic_tmp117.QwiicTMP117.get_conversion_mode (   self)

This function reads the mode for the conversions.

Returns
int The conversion mode

Allowable return values are: kContinuousConversionMode kOneShotMode kShutdownMode

◆ get_high_alert()

def qwiic_tmp117.QwiicTMP117.get_high_alert (   self)

This function reads the 15th bit of the configuration register to tell if the conversion result is higher than the high limit.

This is set as a High Alert flag.

Returns
bool True if the high alert flag is set, otherwise False

◆ get_high_limit()

def qwiic_tmp117.QwiicTMP117.get_high_limit (   self)

This function reads the high limit register that is set by the user.

Returns
float The high limit temperature in degrees celsius

◆ get_high_low_alert()

def qwiic_tmp117.QwiicTMP117.get_high_low_alert (   self)

This function reads configuration register and saves the high and low alert flags.

Use this function if you need to read the alert flags before they are cleared.

Returns
list of bool The high and low alert flags in a list [low, high]

Index into the list with the kLowAlertIdx and kHighAlertIdx constants

◆ get_low_alert()

def qwiic_tmp117.QwiicTMP117.get_low_alert (   self)

This function reads the 14th bit of the configuration register to tell if the conversion result is lower than the low limit.

This is set as a Low Alert flag.

Returns
bool True if the low alert flag is set, otherwise False

◆ get_low_limit()

def qwiic_tmp117.QwiicTMP117.get_low_limit (   self)

This function reads the low limit register that is set by the user.

Returns
float The low limit temperature in degrees celsius

◆ get_temperature_offset()

def qwiic_tmp117.QwiicTMP117.get_temperature_offset (   self)

This function reads the temperature offset value from the device.

Returns
float The temperature offset value

◆ is_connected()

def qwiic_tmp117.QwiicTMP117.is_connected (   self)

Determines if this device is connected.

Returns
bool True if connected, otherwise False

◆ read_register()

def qwiic_tmp117.QwiicTMP117.read_register (   self,
  register 
)

Reads a register from the device.

Parameters
intregister: The register to read
Returns
int The 16-bit value read from the register

Used because the device returns bytes as big-endian

◆ read_temp_c()

def qwiic_tmp117.QwiicTMP117.read_temp_c (   self)

This function reads the temperature reading from the sensor and returns the value in degrees celsius.

Returns
float The temperature in degrees celsius

◆ read_temp_f()

def qwiic_tmp117.QwiicTMP117.read_temp_f (   self)

This function calculates the fahrenheit reading from the celsius reading initially found.

Returns
float The temperature in degrees fahrenheit

◆ set_alert_function_mode()

def qwiic_tmp117.QwiicTMP117.set_alert_function_mode (   self,
  setAlertMode 
)

This function sets the alert function mode to either "alert" or "therm" mode.

Parameters
boolsetAlertMode: The alert mode to set

Allowable setAlertMode values are: kThermMode kAlertMode

Returns
bool True if successful, otherwise False

◆ set_continuous_conversion_mode()

def qwiic_tmp117.QwiicTMP117.set_continuous_conversion_mode (   self)

This function sets the conversion mode of the sensor to be continuous.

The TMP117 defaults to Continuous Conversion Mode on reset.

◆ set_conversion_average_mode()

def qwiic_tmp117.QwiicTMP117.set_conversion_average_mode (   self,
  convMode 
)

This function sets the conversion averaging mode of the device when in Continuous Conversion Mode.

Parameters
intconvMode: The conversion averaging mode to set

Allowable convMode values are: kConvAvgNone kConvAvg8 kConvAvg32 kConvAvg64

Returns
bool True if successful, otherwise False

◆ set_conversion_cycle_bit()

def qwiic_tmp117.QwiicTMP117.set_conversion_cycle_bit (   self,
  conv 
)

This function sets the conversion cycle time bit in Continuous Conversion mode.

The times for the conversions can be found below. The user puts in 0-7 and it will return the cycle time accoring to the values in the chart.

Conversion Cycle Time in CC Mode (found on the datasheet page 27 table 7) AVG 0 1 2 3 CONV averaging (0) (8) (32) (64) 0 15.5ms 125ms 500ms 1s
1 125ms 125ms 500ms 1s
2 250ms 250ms 500ms 1s
3 500ms 500ms 500ms 1s
4 1s 1s 1s 1s
5 4s 4s 4s 4s
6 8s 8s 8s 8s
7 16s 16s 16s 16s

Parameters
intconv: The conversion cycle time bit to set

Allowable conv values are 0-7

Returns
bool True if successful, otherwise False

◆ set_high_limit()

def qwiic_tmp117.QwiicTMP117.set_high_limit (   self,
  highLimit 
)

This function allows the user to set the high limit register to whatever specified value, as long as in the range for the temperature sensor.

This function can be used as a threshold for Therm mode and or Alert mode

Parameters
floathighLimit: The high limit temperature in degrees celsius

◆ set_low_limit()

def qwiic_tmp117.QwiicTMP117.set_low_limit (   self,
  lowLimit 
)

This function allows the user to set the low limit register to whatever specified value, as long as in the range for the temperature sensor.

This function can be used as a threshold for Therm mode and or Alert mode.

Parameters
floatlowLimit: The low limit temperature in degrees celsius

◆ set_one_shot_mode()

def qwiic_tmp117.QwiicTMP117.set_one_shot_mode (   self)

This function sets the conversion mode of the sensor to be in one shot mode.

The TMP117 defaults to Continuous Conversion Mode on reset.

◆ set_shutdown_mode()

def qwiic_tmp117.QwiicTMP117.set_shutdown_mode (   self)

This function sets the conversion mode of the sensor to be in shutdown mode.

The TMP117 defaults to Continuous Conversion Mode on reset.

◆ set_temperature_offset()

def qwiic_tmp117.QwiicTMP117.set_temperature_offset (   self,
  offset 
)

This function sets the temperature offset value on the device.

Parameters
floatoffset: The offset value to set

◆ soft_reset()

def qwiic_tmp117.QwiicTMP117.soft_reset (   self)

This function performs a software reset, loading all the default values into the configuration register.

◆ write_register()

def qwiic_tmp117.QwiicTMP117.write_register (   self,
  register,
  value 
)

Writes a value to a register on the device.

Parameters
intregister: The register to write to
intvalue: The 16-bit value to write to the register

Used because the device expects bytes as big-endian

Member Data Documentation

◆ address

qwiic_tmp117.QwiicTMP117.address

◆ available_addresses

qwiic_tmp117.QwiicTMP117.available_addresses = _AVAILABLE_I2C_ADDRESS
static

◆ device_name

qwiic_tmp117.QwiicTMP117.device_name = _DEFAULT_NAME
static

◆ kAlertMode

int qwiic_tmp117.QwiicTMP117.kAlertMode = 0
static

◆ kConfigAvgMask

int qwiic_tmp117.QwiicTMP117.kConfigAvgMask = 0b11 << kConfigAvgShift
static

◆ kConfigAvgShift

int qwiic_tmp117.QwiicTMP117.kConfigAvgShift = 5
static

◆ kConfigConvMask

int qwiic_tmp117.QwiicTMP117.kConfigConvMask = 0b111 << kConfigConvShift
static

◆ kConfigConvShift

int qwiic_tmp117.QwiicTMP117.kConfigConvShift = 7
static

◆ kConfigDataReadyMask

int qwiic_tmp117.QwiicTMP117.kConfigDataReadyMask = 0b1 << kConfigDataReadyShift
static

◆ kConfigDataReadyShift

int qwiic_tmp117.QwiicTMP117.kConfigDataReadyShift = 13
static

◆ kConfigDeviceIdMask

int qwiic_tmp117.QwiicTMP117.kConfigDeviceIdMask = 0xFFF
static

◆ kConfigDeviceIdShift

int qwiic_tmp117.QwiicTMP117.kConfigDeviceIdShift = 0
static

◆ kConfigDrAlertMask

int qwiic_tmp117.QwiicTMP117.kConfigDrAlertMask = 0b1 << kConfigDrAlertShift
static

◆ kConfigDrAlertShift

int qwiic_tmp117.QwiicTMP117.kConfigDrAlertShift = 2
static

◆ kConfigEepromBusyMask

int qwiic_tmp117.QwiicTMP117.kConfigEepromBusyMask = 0b1 << kConfigEepromBusyShift
static

◆ kConfigEepromBusyShift

int qwiic_tmp117.QwiicTMP117.kConfigEepromBusyShift = 12
static

◆ kConfigHighAlertMask

int qwiic_tmp117.QwiicTMP117.kConfigHighAlertMask = 0b1 << kConfigHighAlertShift
static

◆ kConfigHighAlertShift

int qwiic_tmp117.QwiicTMP117.kConfigHighAlertShift = 15
static

◆ kConfigLowAlertMask

int qwiic_tmp117.QwiicTMP117.kConfigLowAlertMask = 0b1 << kConfigLowAlertShift
static

◆ kConfigLowAlertShift

int qwiic_tmp117.QwiicTMP117.kConfigLowAlertShift = 14
static

◆ kConfigModMask

int qwiic_tmp117.QwiicTMP117.kConfigModMask = 0b11 << kConfigModShift
static

◆ kConfigModShift

int qwiic_tmp117.QwiicTMP117.kConfigModShift = 10
static

◆ kConfigPolMask

int qwiic_tmp117.QwiicTMP117.kConfigPolMask = 0b1 << kConfigPolShift
static

◆ kConfigPolShift

int qwiic_tmp117.QwiicTMP117.kConfigPolShift = 3
static

◆ kConfigRevMask

int qwiic_tmp117.QwiicTMP117.kConfigRevMask = 0xF << kConfigRevShift
static

◆ kConfigRevShift

int qwiic_tmp117.QwiicTMP117.kConfigRevShift = 12
static

◆ kConfigSoftResetMask

int qwiic_tmp117.QwiicTMP117.kConfigSoftResetMask = 0b1 << kConfigSoftResetShift
static

◆ kConfigSoftResetShift

int qwiic_tmp117.QwiicTMP117.kConfigSoftResetShift = 1
static

◆ kConfigTNaMask

int qwiic_tmp117.QwiicTMP117.kConfigTNaMask = 0b1 << kConfigTNaShift
static

◆ kConfigTNaShift

int qwiic_tmp117.QwiicTMP117.kConfigTNaShift = 4
static

◆ kContinuousConversionMode

int qwiic_tmp117.QwiicTMP117.kContinuousConversionMode = 0b00
static

◆ kConvAvg32

int qwiic_tmp117.QwiicTMP117.kConvAvg32 = 0b10
static

◆ kConvAvg64

int qwiic_tmp117.QwiicTMP117.kConvAvg64 = 0b11
static

◆ kConvAvg8

int qwiic_tmp117.QwiicTMP117.kConvAvg8 = 0b01
static

◆ kConvAvgNone

int qwiic_tmp117.QwiicTMP117.kConvAvgNone = 0b00
static

◆ kDeviceIdValue

int qwiic_tmp117.QwiicTMP117.kDeviceIdValue = 0x0117
static

◆ kHighAlertIdx

int qwiic_tmp117.QwiicTMP117.kHighAlertIdx = 1
static

◆ kLowAlertIdx

int qwiic_tmp117.QwiicTMP117.kLowAlertIdx = 0
static

◆ kOneShotMode

int qwiic_tmp117.QwiicTMP117.kOneShotMode = 0b11
static

◆ kRegConfiguration

int qwiic_tmp117.QwiicTMP117.kRegConfiguration = 0x01
static

◆ kRegDeviceId

int qwiic_tmp117.QwiicTMP117.kRegDeviceId = 0x0F
static

◆ kRegEeprom1

int qwiic_tmp117.QwiicTMP117.kRegEeprom1 = 0x05
static

◆ kRegEeprom2

int qwiic_tmp117.QwiicTMP117.kRegEeprom2 = 0x06
static

◆ kRegEeprom3

int qwiic_tmp117.QwiicTMP117.kRegEeprom3 = 0x08
static

◆ kRegEepromUl

int qwiic_tmp117.QwiicTMP117.kRegEepromUl = 0x04
static

◆ kRegTempOffset

int qwiic_tmp117.QwiicTMP117.kRegTempOffset = 0x07
static

◆ kRegTempResult

int qwiic_tmp117.QwiicTMP117.kRegTempResult = 0x00
static

◆ kRegTHighLimit

int qwiic_tmp117.QwiicTMP117.kRegTHighLimit = 0x02
static

◆ kRegTLowLimit

int qwiic_tmp117.QwiicTMP117.kRegTLowLimit = 0x03
static

◆ kShutdownMode

int qwiic_tmp117.QwiicTMP117.kShutdownMode = 0b01
static

◆ kThermMode

int qwiic_tmp117.QwiicTMP117.kThermMode = 1
static

◆ kTmp117Resolution

float qwiic_tmp117.QwiicTMP117.kTmp117Resolution = 0.0078125
static

Property Documentation

◆ connected

qwiic_tmp117.QwiicTMP117.connected = property(is_connected)
static

The documentation for this class was generated from the following file: