Adafruit TMP117 Library
Public Member Functions | List of all members
Adafruit_TMP117 Class Reference

Class that stores state and functions for interacting with the TMP117 High-Accuracy Temperature Sensor. More...

#include <Adafruit_TMP117.h>

Public Member Functions

 Adafruit_TMP117 ()
 Construct a new Adafruit_TMP117::Adafruit_TMP117 object.
 
 ~Adafruit_TMP117 ()
 Destroy the Adafruit_TMP117::Adafruit_TMP117 object.
 
bool begin (uint8_t i2c_addr=TMP117_I2CADDR_DEFAULT, TwoWire *wire=&Wire, int32_t sensor_id=117)
 Sets up the hardware and initializes I2C. More...
 
void reset (void)
 Performs a software reset initializing registers to their power on state.
 
void interruptsActiveLow (bool active_low)
 Sets the polarity of the INT pin. More...
 
bool interruptsActiveLow (void)
 Get the polarity of the INT pin. More...
 
bool getEvent (sensors_event_t *temp)
 Gets the pressure sensor and temperature values as sensor events. More...
 
bool getAlerts (tmp117_alerts_t *alerts)
 Get the current state of the alert flags. More...
 
bool thermAlertModeEnabled (bool therm_enabled)
 Enable or disable "THERM" alert mode. More...
 
bool thermAlertModeEnabled (void)
 Get the current enable status of the "THERM" alert mode. More...
 
tmp117_average_count_t getAveragedSampleCount (void)
 Read the current number of samples that are averaged to calculate the reported temperature. More...
 
bool setAveragedSampleCount (tmp117_average_count_t count)
 Set the number of raw measurements that are averaged into the reported temperature. More...
 
float getOffset (void)
 Read the current temperature offset. More...
 
bool setOffset (float offset)
 Write a new temperature offset. More...
 
float getLowThreshold (void)
 Read the current low temperature threshold. More...
 
bool setLowThreshold (float low_threshold)
 Set a new low temperature threshold. More...
 
float getHighThreshold (void)
 Read the current high temperature threshold. More...
 
bool setHighThreshold (float high_threshold)
 Set a new high temperature threshold. More...
 
tmp117_delay_t getReadDelay (void)
 Get current setting for the minimum delay between calculated temperature reads. More...
 
bool setReadDelay (tmp117_delay_t delay)
 Set a new minimum delay between calculated reads. More...
 
tmp117_mode_t getMeasurementMode (void)
 Read the active measurement mode. More...
 
bool setMeasurementMode (tmp117_mode_t mode)
 Set a new measurement mode. More...
 

Detailed Description

Class that stores state and functions for interacting with the TMP117 High-Accuracy Temperature Sensor.

Member Function Documentation

◆ begin()

bool Adafruit_TMP117::begin ( uint8_t  i2c_address = TMP117_I2CADDR_DEFAULT,
TwoWire *  wire = &Wire,
int32_t  sensor_id = 117 
)

Sets up the hardware and initializes I2C.

Parameters
i2c_addressThe I2C address to be used.
wireThe Wire object to be used for I2C connections.
sensor_idThe unique ID to differentiate the sensors from others
Returns
True if initialization was successful, otherwise false.

◆ interruptsActiveLow() [1/2]

void Adafruit_TMP117::interruptsActiveLow ( bool  active_low)

Sets the polarity of the INT pin.

Parameters
active_lowSet to true to make the pin active low

◆ interruptsActiveLow() [2/2]

bool Adafruit_TMP117::interruptsActiveLow ( void  )

Get the polarity of the INT pin.

Returns
active_low

true: INT pin is active when low false: INT pin is active when high

◆ getEvent()

bool Adafruit_TMP117::getEvent ( sensors_event_t *  temp)

Gets the pressure sensor and temperature values as sensor events.

Parameters
tempSensor event object that will be populated with temp data
Returns
True

◆ getAlerts()

bool Adafruit_TMP117::getAlerts ( tmp117_alerts_t alerts)

Get the current state of the alert flags.

NOTE: Because the high/low temperature status is based on temperature data, their status returned by this method is only updated when new temperature data is available. This ensures that the reported value is based on temperature data and not a cleared but not updated alert status.

Parameters
alertsPointer to an alerts struct to be filled with the trigger status of the alerts
Returns
true:success false: failure

◆ thermAlertModeEnabled() [1/2]

bool Adafruit_TMP117::thermAlertModeEnabled ( bool  therm_enabled)

Enable or disable "THERM" alert mode.

WHen enabled, the 'low' alert will never trigger and acts in combination with the high threshold to determine the behavior of the high temperature alert.

In "Therm" mode, the "high" temperature alert statys triggered until the measured temperature goes below the 'low' temperature threshold, allowing it to act like a hysteresis value to prevent thrashing around the threshold temperature.

Parameters
therm_enabled
Returns
true:success false:failure

◆ thermAlertModeEnabled() [2/2]

bool Adafruit_TMP117::thermAlertModeEnabled ( void  )

Get the current enable status of the "THERM" alert mode.

Returns
true: Therm mode enabled
false Normal high/low alert mode enabled

◆ getAveragedSampleCount()

tmp117_average_count_t Adafruit_TMP117::getAveragedSampleCount ( void  )

Read the current number of samples that are averaged to calculate the reported temperature.

Returns
tmp117_average_count_t The current average setting enum value

◆ setAveragedSampleCount()

bool Adafruit_TMP117::setAveragedSampleCount ( tmp117_average_count_t  count)

Set the number of raw measurements that are averaged into the reported temperature.

Each sample read takes 15.5ms so the higher the number of averaged samples, the longer the amount of time between new measurements. For larger average counts the amount of time required for a new measurement will exceed the interval specified by setReadDelay

Parameters
countThe tmp117_average_count_t that specifies the desired sample count
Returns
true:success false:failure

◆ getOffset()

float Adafruit_TMP117::getOffset ( void  )

Read the current temperature offset.

Returns
float The currently set temperature offset.

◆ setOffset()

bool Adafruit_TMP117::setOffset ( float  offset)

Write a new temperature offset.

Parameters
offsetThe new temperature offset in degrees C. When set, the given offset will be added to all future temperature reads reported by getEvent
Returns
true: success false: failure

◆ getLowThreshold()

float Adafruit_TMP117::getLowThreshold ( void  )

Read the current low temperature threshold.

Returns
float The current low temperature threshold in degrees C

◆ setLowThreshold()

bool Adafruit_TMP117::setLowThreshold ( float  low_threshold)

Set a new low temperature threshold.

Parameters
low_thresholdThe new threshold to be set, in degrees C. An alert will trigger when the current temperature measurement is lower than the given threshold.
Returns
true:success false: failure

◆ getHighThreshold()

float Adafruit_TMP117::getHighThreshold ( void  )

Read the current high temperature threshold.

Returns
float The current high temperature threshold in degrees C

◆ setHighThreshold()

bool Adafruit_TMP117::setHighThreshold ( float  high_threshold)

Set a new high temperature threshold.

Parameters
high_thresholdThe new threshold to be set, in degrees C. An alert will trigger when the current temperature measurement is higher than the given threshold.
Returns
true:success false: failure

◆ getReadDelay()

tmp117_delay_t Adafruit_TMP117::getReadDelay ( void  )

Get current setting for the minimum delay between calculated temperature reads.

Returns
tmp117_delay_t The minimum time between new temperature measurements. This amount of time will be exceeded if the time required for the configured number of averaged reads is more than the delay setting.

◆ setReadDelay()

bool Adafruit_TMP117::setReadDelay ( tmp117_delay_t  delay)

Set a new minimum delay between calculated reads.

Parameters
delayThe minimum time between new temperature measurements as a tmp117_delay_t. This amount of time will be exceeded if the time required for the configured number of averaged reads is more than the delay setting.
Returns
true:success false:failure

◆ getMeasurementMode()

tmp117_mode_t Adafruit_TMP117::getMeasurementMode ( void  )

Read the active measurement mode.

Returns
tmp117_mode_t The current measurement mode.

◆ setMeasurementMode()

bool Adafruit_TMP117::setMeasurementMode ( tmp117_mode_t  mode)

Set a new measurement mode.

Parameters
modethe new mode to set, a tmp117_mode_t. If mode is TMP117_MODE_ONE_SHOT, initiate a new reading before switching to TMP117_MODE_SHUTDOWN.
Returns
true:success false:failure

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