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 
67 /**************************************************************************/
71 /**************************************************************************/
73 public:
75  boolean begin(uint8_t i2c_addr = MCP9600_I2CADDR_DEFAULT,
76  TwoWire *theWire = &Wire);
77 
78  float readThermocouple(void);
79  float readAmbient(void);
80 
81  void enable(bool flag);
82  bool enabled(void);
83 
86 
87  uint8_t getFilterCoefficient(void);
88  void setFilterCoefficient(uint8_t);
89 
90  void setADCresolution(MCP9600_ADCResolution resolution);
92  int32_t readADC(void);
93 
94  void setAlertTemperature(uint8_t alert, float temp);
95  float getAlertTemperature(uint8_t alert);
96  void configureAlert(uint8_t alert, bool enabled, bool rising,
97  bool alertColdJunction = false, bool activeHigh = false,
98  bool interruptMode = false);
99 
100  uint8_t getStatus(void);
101 
102 protected:
103  uint8_t _device_id = 0;
104 private:
105  Adafruit_I2CDevice *i2c_dev;
106  Adafruit_I2CRegister *_config_reg;
107 };
108 
109 #endif // #define __ADAFRUIT_MCP9600_H__
uint8_t _device_id
The DEVICE ID high byte for MCP9600 or MCP9601.
Definition: Adafruit_MCP9600.h:103
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
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:72
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
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