forked from adafruit/Adafruit_TMP006
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdafruit_TMP006.h
81 lines (65 loc) · 2.16 KB
/
Adafruit_TMP006.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/***************************************************
This is a library for the TMP006 Temp Sensor
Designed specifically to work with the Adafruit TMP006 Breakout
----> https://www.adafruit.com/products/1296
These displays use I2C to communicate, 2 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#define TMP006_B0 -0.0000294
#define TMP006_B1 -0.00000057
#define TMP006_B2 0.00000000463
#define TMP006_C2 13.4
#define TMP006_TREF 298.15
#define TMP006_A2 -0.00001678
#define TMP006_A1 0.00175
#define TMP006_S0 6.4 // * 10^-14
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
//#include <Adafruit_Sensor.h>
#ifdef __AVR_ATtiny85__
#include "TinyWireM.h"
#define Wire TinyWireM
#else
#include "Wire.h"
#endif
// uncomment for debugging!
//#define TMP006_DEBUG 1
#define TMP006_CONFIG 0x02
#define TMP006_CFG_RESET 0x8000
#define TMP006_CFG_MODEON 0x7000
#define TMP006_CFG_1SAMPLE 0x0000
#define TMP006_CFG_2SAMPLE 0x0200
#define TMP006_CFG_4SAMPLE 0x0400
#define TMP006_CFG_8SAMPLE 0x0600
#define TMP006_CFG_16SAMPLE 0x0800
#define TMP006_CFG_DRDYEN 0x0100
#define TMP006_CFG_DRDY 0x0080
#define TMP006_I2CADDR 0x40
#define TMP006_MANID 0xFE
#define TMP006_DEVID 0xFF
#define TMP006_VOBJ 0x00
#define TMP006_TAMB 0x01
class Adafruit_TMP006 {
public:
Adafruit_TMP006(uint8_t addr = TMP006_I2CADDR);
bool begin(uint16_t samplerate = TMP006_CFG_16SAMPLE); // by default go highres
bool sleep(); // Put chip into low power mode (disables temperature measurements).
bool wake(); // Wake from low power mode.
bool drdy(); // check data ready bit
int16_t readRawDieTemperature(void);
int16_t readRawVoltage(void);
double readObjTempC(void);
double readDieTempC(void);
private:
uint8_t _addr;
uint16_t read16(uint8_t addr);
bool write16(uint8_t addr, uint16_t data);
};