-
Notifications
You must be signed in to change notification settings - Fork 0
/
Adafruit_MCP9808.h
82 lines (68 loc) · 2.23 KB
/
Adafruit_MCP9808.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
81
82
/**************************************************************************/
/*!
@file Adafruit_MCP9808.h
@author K. Townsend (Adafruit Industries)
@license BSD (see license.txt)
This is a library for the Adafruit MCP9808 Temp Sensor breakout board
----> http://www.adafruit.com/products/1782
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section HISTORY
v1.0 - First release
*/
#ifndef __Adafruit_MCP9808_H__
#define __Adafruit_MCP9808_H__
/**************************************************************************/
//should move SERIAL_DEBUG to params include
//#define SERIAL_DEBUG
#ifdef ARDUINO
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#ifdef __AVR_ATtiny85__
#include "TinyWireM.h"
#define Wire TinyWireM
#else
#include <Wire.h>
#endif
#else //for Photon
#include "application.h"
#endif
#include "parms.h"
#define MCP9808_I2CADDR_DEFAULT 0x18
//Define Address in parms.h
//#define MCP9808_I2CADDR 0X1A //0x1A //A1 HIGH, A0,A2 LOW
#define MCP9808_REG_CONFIG 0x01
#define MCP9808_REG_CONFIG_SHUTDOWN 0x0100
#define MCP9808_REG_CONFIG_CRITLOCKED 0x0080
#define MCP9808_REG_CONFIG_WINLOCKED 0x0040
#define MCP9808_REG_CONFIG_INTCLR 0x0020
#define MCP9808_REG_CONFIG_ALERTSTAT 0x0010
#define MCP9808_REG_CONFIG_ALERTCTRL 0x0008
#define MCP9808_REG_CONFIG_ALERTSEL 0x0004
#define MCP9808_REG_CONFIG_ALERTPOL 0x0002
#define MCP9808_REG_CONFIG_ALERTMODE 0x0001
#define MCP9808_REG_UPPER_TEMP 0x02
#define MCP9808_REG_LOWER_TEMP 0x03
#define MCP9808_REG_CRIT_TEMP 0x04
#define MCP9808_REG_AMBIENT_TEMP 0x05
#define MCP9808_REG_MANUF_ID 0x06
#define MCP9808_REG_DEVICE_ID 0x07
class Adafruit_MCP9808 {
public:
Adafruit_MCP9808();
// 9808 is slave, photon is master
// why not just begin() ??
uint16_t begin(uint8_t a = MCP9808_I2CADDR);
float readTempF( void );
float readTempC( void );
int shutdown_wake( uint8_t sw_ID );
void write16(uint8_t reg, uint16_t val);
uint16_t read16(uint8_t reg);
private:
uint8_t _i2caddr;
};
#endif