forked from lincomatic/open_evse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Adafruit_TMP007.h
68 lines (54 loc) · 1.86 KB
/
Adafruit_TMP007.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
/***************************************************
This is a library for the TMP007 Temp Sensor
Designed specifically to work with the Adafruit TMP007 Breakout
----> https://www.adafruit.com/products/2023
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
****************************************************/
#pragma once
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "./Wire.h"
// uncomment for debugging!
//#define TMP007_DEBUG 1
#define TMP007_VOBJ 0x00
#define TMP007_TDIE 0x01
#define TMP007_CONFIG 0x02
#define TMP007_TOBJ 0x03
#define TMP007_STATUS 0x04
#define TMP007_STATMASK 0x05
#define TMP007_CFG_RESET 0x8000
#define TMP007_CFG_MODEON 0x1000
#define TMP007_CFG_1SAMPLE 0x0000
#define TMP007_CFG_2SAMPLE 0x0200
#define TMP007_CFG_4SAMPLE 0x0400
#define TMP007_CFG_8SAMPLE 0x0600
#define TMP007_CFG_16SAMPLE 0x0800
#define TMP007_CFG_ALERTEN 0x0100
#define TMP007_CFG_ALERTF 0x0080
#define TMP007_CFG_TRANSC 0x0040
#define TMP007_STAT_ALERTEN 0x8000
#define TMP007_STAT_CRTEN 0x4000
#define TMP007_I2CADDR 0x40
#define TMP007_DEVID 0x1F
class Adafruit_TMP007 {
public:
Adafruit_TMP007(uint8_t addr = TMP007_I2CADDR);
boolean begin(uint8_t samplerate = TMP007_CFG_4SAMPLE); // by default go to once per second
int16_t readRawDieTemperature(void);
int16_t readRawVoltage(void);
int16_t readObjTempC10(void);
int16_t readDieTempC(void);
private:
uint8_t _addr;
uint16_t read16(uint8_t addr);
void write16(uint8_t addr, uint16_t data);
};