1 | /***************************************************
|
---|
2 | This is a library for the TMP007 Temp Sensor
|
---|
3 |
|
---|
4 | Designed specifically to work with the Adafruit TMP007 Breakout
|
---|
5 | ----> https://www.adafruit.com/products/2023
|
---|
6 |
|
---|
7 | These displays use I2C to communicate, 2 pins are required to
|
---|
8 | interface
|
---|
9 | Adafruit invests time and resources providing this open source code,
|
---|
10 | please support Adafruit and open-source hardware by purchasing
|
---|
11 | products from Adafruit!
|
---|
12 |
|
---|
13 | Written by Limor Fried/Ladyada for Adafruit Industries.
|
---|
14 | BSD license, all text above must be included in any redistribution
|
---|
15 | ****************************************************/
|
---|
16 |
|
---|
17 | #if (ARDUINO >= 100)
|
---|
18 | #include "Arduino.h"
|
---|
19 | #else
|
---|
20 | #include "WProgram.h"
|
---|
21 | #endif
|
---|
22 | #include "Wire.h"
|
---|
23 |
|
---|
24 | // uncomment for debugging!
|
---|
25 | //#define TMP007_DEBUG 1
|
---|
26 |
|
---|
27 | #define TMP007_VOBJ 0x00
|
---|
28 | #define TMP007_TDIE 0x01
|
---|
29 | #define TMP007_CONFIG 0x02
|
---|
30 | #define TMP007_TOBJ 0x03
|
---|
31 | #define TMP007_STATUS 0x04
|
---|
32 | #define TMP007_STATMASK 0x05
|
---|
33 |
|
---|
34 | #define TMP007_CFG_RESET 0x8000
|
---|
35 | #define TMP007_CFG_MODEON 0x1000
|
---|
36 | #define TMP007_CFG_1SAMPLE 0x0000
|
---|
37 | #define TMP007_CFG_2SAMPLE 0x0200
|
---|
38 | #define TMP007_CFG_4SAMPLE 0x0400
|
---|
39 | #define TMP007_CFG_8SAMPLE 0x0600
|
---|
40 | #define TMP007_CFG_16SAMPLE 0x0800
|
---|
41 | #define TMP007_CFG_ALERTEN 0x0100
|
---|
42 | #define TMP007_CFG_ALERTF 0x0080
|
---|
43 | #define TMP007_CFG_TRANSC 0x0040
|
---|
44 |
|
---|
45 | #define TMP007_STAT_ALERTEN 0x8000
|
---|
46 | #define TMP007_STAT_CRTEN 0x4000
|
---|
47 |
|
---|
48 | #define TMP007_I2CADDR 0x40
|
---|
49 | #define TMP007_DEVID 0x1F
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 | class Adafruit_TMP007 {
|
---|
54 | public:
|
---|
55 | Adafruit_TMP007(uint8_t addr = TMP007_I2CADDR);
|
---|
56 | boolean begin(uint16_t samplerate = 0); // by default go highres
|
---|
57 |
|
---|
58 | int16_t readRawDieTemperature(void);
|
---|
59 | int16_t readRawVoltage(void);
|
---|
60 | double readObjTempC(void);
|
---|
61 | double readDieTempC(void);
|
---|
62 |
|
---|
63 | private:
|
---|
64 | uint8_t _addr;
|
---|
65 | uint16_t read16(uint8_t addr);
|
---|
66 | void write16(uint8_t addr, uint16_t data);
|
---|
67 | };
|
---|
68 |
|
---|