Adafruit MCP960x Library
Adafruit_MCP9600.h
Go to the documentation of this file.
1 /**************************************************************************/
15 /**************************************************************************/
16 #ifndef __ADAFRUIT_MCP9600_H__
17 #define __ADAFRUIT_MCP9600_H__
18 
19 #include <Adafruit_I2CDevice.h>
20 #include <Adafruit_I2CRegister.h>
21 #include <Arduino.h>
22 #include <Wire.h>
23 
25 #define MCP9600_I2CADDR_DEFAULT 0x67
26 
27 #define MCP9600_HOTJUNCTION 0x00
28 #define MCP9600_JUNCTIONDELTA 0x01
29 #define MCP9600_COLDJUNCTION 0x02
30 #define MCP9600_RAWDATAADC 0x03
31 #define MCP9600_STATUS 0x04
32 #define MCP9600_SENSORCONFIG 0x05
33 #define MCP9600_DEVICECONFIG 0x06
34 #define MCP9600_DEVICEID 0x20
35 #define MCP9600_ALERTCONFIG_1 0x08
36 #define MCP9600_ALERTHYST_1 0x0C
37 #define MCP9600_ALERTLIMIT_1 0x10
38 
39 #define MCP960X_STATUS_ALERT1 0x01
40 #define MCP960X_STATUS_ALERT2 0x02
41 #define MCP960X_STATUS_ALERT3 0x04
42 #define MCP960X_STATUS_ALERT4 0x08
43 #define MCP960X_STATUS_INPUTRANGE 0x10
44 #define MCP960X_STATUS_THUPDATE 0x40
45 #define MCP960X_STATUS_BURST 0x80
46 
47 
48 typedef enum _themotype {
49  MCP9600_TYPE_K,
50  MCP9600_TYPE_J,
51  MCP9600_TYPE_T,
52  MCP9600_TYPE_N,
53  MCP9600_TYPE_S,
54  MCP9600_TYPE_E,
55  MCP9600_TYPE_B,
56  MCP9600_TYPE_R,
58 
60 typedef enum _resolution {
61  MCP9600_ADCRESOLUTION_18,
62  MCP9600_ADCRESOLUTION_16,
63  MCP9600_ADCRESOLUTION_14,
64  MCP9600_ADCRESOLUTION_12,
66 
68 typedef enum {
74 
75 /**************************************************************************/
79 /**************************************************************************/
81 public:
83  boolean begin(uint8_t i2c_addr = MCP9600_I2CADDR_DEFAULT,
84  TwoWire *theWire = &Wire);
85 
86  float readThermocouple(void);
87  float readAmbient(void);
88 
89  void enable(bool flag);
90  bool enabled(void);
91 
94 
95  uint8_t getFilterCoefficient(void);
96  void setFilterCoefficient(uint8_t);
97 
98  void setADCresolution(MCP9600_ADCResolution resolution);
100  int32_t readADC(void);
101 
103 
104  void setAlertTemperature(uint8_t alert, float temp);
105  float getAlertTemperature(uint8_t alert);
106  void configureAlert(uint8_t alert, bool enabled, bool rising,
107  bool alertColdJunction = false, bool activeHigh = false,
108  bool interruptMode = false);
109 
110  uint8_t getStatus(void);
111 
112 protected:
113  uint8_t _device_id = 0;
114 private:
115  Adafruit_I2CDevice *i2c_dev;
116  Adafruit_I2CRegister *_config_reg;
117 };
118 
119 #endif // #define __ADAFRUIT_MCP9600_H__
uint8_t _device_id
The DEVICE ID high byte for MCP9600 or MCP9601.
Definition: Adafruit_MCP9600.h:113
uint8_t getFilterCoefficient(void)
The desired filter coefficient getter.
Definition: Adafruit_MCP9600.cpp:240
void enable(bool flag)
Whether to have the sensor enabled and working or in sleep mode.
Definition: Adafruit_MCP9600.cpp:122
void setAmbientResolution(Ambient_Resolution res_value)
Sets the resolution for ambient (cold junction) temperature readings.
Definition: Adafruit_MCP9600.cpp:373
0.25°C
Definition: Adafruit_MCP9600.h:69
float readThermocouple(void)
Read temperature at the end of the thermocouple.
Definition: Adafruit_MCP9600.cpp:74
void setAlertTemperature(uint8_t alert, float temp)
Setter for alert temperature setting.
Definition: Adafruit_MCP9600.cpp:296
void setThermocoupleType(MCP9600_ThemocoupleType)
The desired thermocouple type setter.
Definition: Adafruit_MCP9600.cpp:224
void setFilterCoefficient(uint8_t)
The desired filter coefficient setter.
Definition: Adafruit_MCP9600.cpp:256
int32_t readADC(void)
Read the raw ADC voltage, say for self calculating a temperature.
Definition: Adafruit_MCP9600.cpp:186
enum _resolution MCP9600_ADCResolution
MCP9600 driver.
Definition: Adafruit_MCP9600.h:80
void configureAlert(uint8_t alert, bool enabled, bool rising, bool alertColdJunction=false, bool activeHigh=false, bool interruptMode=false)
Configure temperature alert.
Definition: Adafruit_MCP9600.cpp:324
boolean begin(uint8_t i2c_addr=MCP9600_I2CADDR_DEFAULT, TwoWire *theWire=&Wire)
Sets up the I2C connection and tests that the sensor was found.
Definition: Adafruit_MCP9600.cpp:43
Adafruit_MCP9600()
Instantiates a new MCP9600 class.
Definition: Adafruit_MCP9600.cpp:32
float getAlertTemperature(uint8_t alert)
Getter for alert temperature setting.
Definition: Adafruit_MCP9600.cpp:273
enum _themotype MCP9600_ThemocoupleType
float readAmbient(void)
Read temperature at the MCP9600 chip body.
Definition: Adafruit_MCP9600.cpp:98
bool enabled(void)
Whether the sensor is enabled and working or in sleep mode.
Definition: Adafruit_MCP9600.cpp:140
#define MCP9600_I2CADDR_DEFAULT
I2C address.
Definition: Adafruit_MCP9600.h:25
0.125°C
Definition: Adafruit_MCP9600.h:70
uint8_t getStatus(void)
Getter for status register.
Definition: Adafruit_MCP9600.cpp:359
MCP9600_ADCResolution getADCresolution(void)
The desired ADC resolution getter.
Definition: Adafruit_MCP9600.cpp:172
_themotype
Definition: Adafruit_MCP9600.h:48
void setADCresolution(MCP9600_ADCResolution resolution)
The desired ADC resolution setter.
Definition: Adafruit_MCP9600.cpp:156
_resolution
Definition: Adafruit_MCP9600.h:60
MCP9600_ThemocoupleType getThermocoupleType(void)
The desired thermocouple type getter.
Definition: Adafruit_MCP9600.cpp:206
0.03125°C
Definition: Adafruit_MCP9600.h:72
0.0625°C
Definition: Adafruit_MCP9600.h:71
Ambient_Resolution
Definition: Adafruit_MCP9600.h:68