A library for STMicroelectronics STTS751 I2C temperature sensor

Dependents:   STTS751_Demo

Embed: (wiki syntax)

« Back to documentation index

STTS751 Class Reference

A library for STMicroelectronics STTS751 I2C temperature sensor. More...

#include <STTS751.h>

Public Types

enum  Model { MODEL_0 = 0x00, MODEL_1 = 0x40 }
 

Device models.

More...
enum  Address { ADDRESS_0 = (0x48 << 1), ADDRESS_1 = (0x49 << 1), ADDRESS_2 = (0x38 << 1), ADDRESS_3 = (0x39 << 1) }
 

I2C slave address selectors The I2C slave address of the device is determined by the pull up register for Addr/~Therm pin.

More...
enum  Resolution { RES_9 = 0x08, RES_10 = 0x00, RES_11 = 0x04, RES_12 = 0x0c }
 

Temperature resolutions.

More...

Public Member Functions

 STTS751 (PinName sda, PinName scl, bool standby=false, Address addr=ADDRESS_3, Model model=MODEL_0)
 Create an STTS751 object connected to the specified I2C pins.
 STTS751 (I2C &_i2c, bool standby=false, Address addr=ADDRESS_3, Model model=MODEL_0)
 Create an STTS751 object connected to the specified I2C port.
void init ()
 Initialize the device.
int addr ()
 The I2C slave address (8bit) of the device.
Resolution resolution ()
 Get the current temperature resolution.
void setResolution (Resolution res=RES_10)
 Set the temperature resolution.
int conversionRate ()
 Get the current conversion rate.
void setConversionRate (int rate)
 Set the conversion rate Set the number of times the temperature value is updated each second.
void setStandbyMode (bool standby)
 Set the device mode.
void start ()
 Start a temperature conversion (in standby mode)
bool ready ()
 Checks that a temperature conversion has finished and the temperature value is available.
float temp (bool nowait=false)
 Obtain the current temperature measurement.
 operator float ()
 A shorthand for temp()

Protected Types

enum  
 

I2C registers.

More...
enum  
 

Configuration register (default 0x00)

  • b7 : MASK1
  • b6 : ~RUN/STOP (0 : continuous conversion mode, 1 : standby mode)
  • b5 : 0
  • b4 : RFU
  • b3 : Tres1
  • b2 : Tres0
  • b1-b0 : RFU.
More...
enum  
 

Status Register (default undefined)

  • b7 : Busy
  • b6 : T_HIGH
  • b5 : T_LOW
  • b4-b1 : RFU
  • b0 : THRM.
More...
enum  
 

Conversion Rate Register (default 4)

  • b7-b4: 0
  • b3-b0: Conversion rate (0..9)
More...

Detailed Description

A library for STMicroelectronics STTS751 I2C temperature sensor.

http://www.st.com/web/catalog/sense_power/FM89/SC294/PF220116

Example:

 #include "mbed.h"
 #include "STTS751.h"

 // I2C pins: p9 = sda, p10 = scl
 STTS751 sensor(p9, p10);

 // You can specify an I2C object instead.
 // I2C i2c(p2, p10);
 // STTS751 sensor(i2c);
 
 int main() {
     // set the temperature resolution to 12bits
     sensor.setResolution(STTS751::RES_12);
     while (true) {
         printf("tmp: %.4f\n", (float)sensor);
         wait(1);
     }
 }

Definition at line 48 of file STTS751.h.


Member Enumeration Documentation

anonymous enum [protected]

I2C registers.

Definition at line 171 of file STTS751.h.

anonymous enum [protected]

Configuration register (default 0x00)

  • b7 : MASK1
  • b6 : ~RUN/STOP (0 : continuous conversion mode, 1 : standby mode)
  • b5 : 0
  • b4 : RFU
  • b3 : Tres1
  • b2 : Tres0
  • b1-b0 : RFU.

Definition at line 199 of file STTS751.h.

anonymous enum [protected]

Status Register (default undefined)

  • b7 : Busy
  • b6 : T_HIGH
  • b5 : T_LOW
  • b4-b1 : RFU
  • b0 : THRM.

Definition at line 212 of file STTS751.h.

anonymous enum [protected]

Conversion Rate Register (default 4)

  • b7-b4: 0
  • b3-b0: Conversion rate (0..9)

Definition at line 223 of file STTS751.h.

enum Address

I2C slave address selectors The I2C slave address of the device is determined by the pull up register for Addr/~Therm pin.

Enumerator:
ADDRESS_0 

pull up resistor = 7.5K

ADDRESS_1 

pull up resistor = 12K

ADDRESS_2 

pull up resistor = 20K

ADDRESS_3 

pull up resistor = 33K or GND (default)

Definition at line 61 of file STTS751.h.

enum Model

Device models.

Enumerator:
MODEL_0 

Model 0 (default)

MODEL_1 

Model 1.

Definition at line 52 of file STTS751.h.

enum Resolution

Temperature resolutions.

Enumerator:
RES_9 

9 bits

RES_10 

10 bits (default)

RES_11 

11 bits

RES_12 

12 bits

Definition at line 70 of file STTS751.h.


Constructor & Destructor Documentation

STTS751 ( PinName  sda,
PinName  scl,
bool  standby = false,
Address  addr = ADDRESS_3,
Model  model = MODEL_0 
)

Create an STTS751 object connected to the specified I2C pins.

Parameters:
sdaI2C data pin
sclI2C clock pin
standbyStandby mode (defaults to false)
addrI2C slave address (defaults to ADDRESS_3)
modelDevice model (defaults to MODEL_0)

Definition at line 21 of file STTS751.cpp.

STTS751 ( I2C &  _i2c,
bool  standby = false,
Address  addr = ADDRESS_3,
Model  model = MODEL_0 
)

Create an STTS751 object connected to the specified I2C port.

Parameters:
i2cI2C port
standbyStandby mode (defaults to false)
addrI2C slave address (defaults to ADDRESS_3)
modelDevice model (defaults to MODEL_0)

Definition at line 26 of file STTS751.cpp.


Member Function Documentation

int addr (  )

The I2C slave address (8bit) of the device.

Returns:
The I2C slave address (8bit) of the device

Definition at line 40 of file STTS751.cpp.

int conversionRate (  )

Get the current conversion rate.

Returns:
The current conversion rate

Definition at line 55 of file STTS751.cpp.

void init (  )

Initialize the device.

Definition at line 31 of file STTS751.cpp.

operator float (  )

A shorthand for temp()

Returns:
The current temperature measurement in Celsius.

Definition at line 96 of file STTS751.cpp.

bool ready (  )

Checks that a temperature conversion has finished and the temperature value is available.

Returns:
true if a temperature conversion has finished and the temperature value is available

Definition at line 79 of file STTS751.cpp.

STTS751::Resolution resolution (  )

Get the current temperature resolution.

Returns:
The current temperature resolution

Definition at line 44 of file STTS751.cpp.

void setConversionRate ( int  rate )

Set the conversion rate Set the number of times the temperature value is updated each second.

The conversion rate (times/second) can be calculated by 2^(rate - 4). Note that rate should be less than 8 if the temperature resolution is 12-bit and should be less than 9 if the temperature resolution is greater than 10-bit

Parameters:
rateConversion rate (0 .. 9)

Definition at line 60 of file STTS751.cpp.

void setResolution ( STTS751::Resolution  res = RES_10 )

Set the temperature resolution.

Parameters:
resResolution (defaults to RES_10)

Definition at line 49 of file STTS751.cpp.

void setStandbyMode ( bool  standby )

Set the device mode.

Parameters:
standbytrue : standby mode, false : continuous conversion mode

Definition at line 64 of file STTS751.cpp.

void start (  )

Start a temperature conversion (in standby mode)

Definition at line 74 of file STTS751.cpp.

float temp ( bool  nowait = false )

Obtain the current temperature measurement.

Parameters:
nowaitIf true, read the temperature value without waiting for finishing a conversion (in standby mode)
Returns:
The current temperature measurement in Celsius.

Definition at line 84 of file STTS751.cpp.