A class library development test using TMP102 (I2C temperature sensor).

test_TMP102.h

Committer:
yasubumi
Date:
2017-11-26
Revision:
1:c9c43b132ed7
Parent:
0:89475bc39c8b
Child:
2:494a328aed3e

File content as of revision 1:c9c43b132ed7:

#include "mbed.h"

// TMP102 I2C slave address(ADD0 connected to GND)
#define ADDR_TMP102     0x90

// TMP102 registers
#define TMP102_Temp     0x00
#define TMP102_Conf     0x01
#define TMP102_Tlow     0x02
#define TMP102_Thigh    0x03

class test_TMP102
{
public:
    test_TMP102(PinName sda, PinName scl, char address = ADDR_TMP102);
    test_TMP102(I2C &i2c_obj, char address = ADDR_TMP102);
    ~test_TMP102();
    void init(void);
    float read(void);
    operator float(void);
private:
    I2C *i2c_p;
    I2C &i2c;
    char adr;
};