Poushen Ou / TMP102

Dependents:   ou_OLED_TMP102 ou_mbed_tmp102

Embed: (wiki syntax)

« Back to documentation index

test_TMP102 Class Reference

test_TMP102 Class Reference

test_TMP102 Class Library to provide very simple interface for mbed More...

#include <test_TMP102.h>

Public Member Functions

 test_TMP102 (PinName sda, PinName scl, char address=ADDR_TMP102)
 Create a test_TMP102 instance connected to specified I2C pins with specified address.
 test_TMP102 (I2C &i2c_obj, char address=ADDR_TMP102)
 Create a test_TMP102 instance connected to specified I2C pins with specified address.
 ~test_TMP102 ()
 Destractor.
void init (void)
 Initialization.
float read (void)
 Read temperature.
float readTempC (void)
 Read temperature.
float readTempF (void)
 Read temperature.
 operator float (void)
 Read temperature.
void setConversionRate (char rate)
 Set the conversion rate (0-3)
void setExtendedMode (bool mode)
 Enable or disable extened mode.
void sleep (void)
 Switch sensor to low power mode.
void wakeup (void)
 Wakeup and start running in normal power mode.
void oneShot (void)
 enter One-Shot mode, and wait for temperature sample complete (about 26ms)

Detailed Description

test_TMP102 Class Library to provide very simple interface for mbed

Example:

 #include "mbed.h"
 #include "test_TMP102.h"

 // make test_TMP102 instance using GPIO pin name.
 test_TMP102 temp0(dp4,dp5);

 // make test_TMP102 instance using I2C object.
 I2C i2c(dp4,dp5);
 test_TMP102 temp1(i2c);

 int main()
 {
     float t0,t1;

     i2c.frequency(400*1000);

     while(1) {
         t0=temp0;
         t1=temp1;
         printf("Temp: %7.3f, %7.3f\r\n", t0, t1);
         wait(1.0);
     }
 }

Definition at line 63 of file test_TMP102.h.


Constructor & Destructor Documentation

test_TMP102 ( PinName  sda,
PinName  scl,
char  address = ADDR_TMP102 
)

Create a test_TMP102 instance connected to specified I2C pins with specified address.

Parameters:
sdaI2C-bus SDA pin
sclI2C-bus SCL pin
address(option) I2C-bus slave address (default: 0x90)

Definition at line 3 of file test_TMP102.cpp.

test_TMP102 ( I2C &  i2c_obj,
char  address = ADDR_TMP102 
)

Create a test_TMP102 instance connected to specified I2C pins with specified address.

Parameters:
i2c_objI2C object (instance)
address(option) I2C-bus slave address (default: 0x90)

Definition at line 8 of file test_TMP102.cpp.

~test_TMP102 (  )

Destractor.

Definition at line 14 of file test_TMP102.cpp.


Member Function Documentation

void init ( void   )

Initialization.

Definition at line 20 of file test_TMP102.cpp.

void oneShot ( void   )

enter One-Shot mode, and wait for temperature sample complete (about 26ms)

Definition at line 132 of file test_TMP102.cpp.

operator float ( void   )

Read temperature.

Returns:
the object returns the read value

Definition at line 97 of file test_TMP102.cpp.

float read ( void   )

Read temperature.

Returns:
value of degree Celsius (in float)

Definition at line 24 of file test_TMP102.cpp.

float readTempC ( void   )

Read temperature.

Returns:
value of degree C (in float)

Definition at line 50 of file test_TMP102.cpp.

float readTempF ( void   )

Read temperature.

Returns:
value of degree F (in float)

Definition at line 55 of file test_TMP102.cpp.

void setConversionRate ( char  rate )

Set the conversion rate (0-3)

Parameters:
rateConversion Rate 0 - 0.25Hz 1 - 1 Hz 2 - 4 Hz (default) 3 - 8 Hz

Definition at line 60 of file test_TMP102.cpp.

void setExtendedMode ( bool  mode )

Enable or disable extened mode.

Parameters:
modeExtend Mode (0 disable, 1 enabled)

Definition at line 79 of file test_TMP102.cpp.

void sleep ( void   )

Switch sensor to low power mode.

Definition at line 102 of file test_TMP102.cpp.

void wakeup ( void   )

Wakeup and start running in normal power mode.

Definition at line 117 of file test_TMP102.cpp.