MCP9808 Class
- ID: MCP9808
- Name: High Accuracy I2C Temperature Sensor
- Category: temp
- Manufacturer: adafruit
- Connection: i2c
- Link: https://learn.adafruit.com/adafruit-mcp9808-precision-i2c-temperature-sensor-guide/overview
- Link: http://ww1.microchip.com/downloads/en/DeviceDoc/25095A.pdf
The MCP9808 digital temperature sensor converts temperatures between -20 deg C and +100 deg C to a digital word with +/- 0.5 deg C (max.) accuracy. The MCP9808 comes with user-programmable registers that provide flexibility for temperature sensing applications. The registers allow user-selectable settings such as Shutdown or low-power modes and the specification of temperature Event and Critical output boundaries. When the temperature changes beyond the specified boundary limits, the MCP9808 outputs an Event signal. The user has the option of setting the event output signal polarity as an active-low or active-high comparator output for thermostat operation, or as temperature event interrupt output for microprocessor-based systems. The event output can also be configured as a Critical temperature output.
Tested with Adafriut MCP9808 board.
Item Index
Methods
Methods
MCP9808
-
bus
-
address
MCP9808 constructor
Parameters:
-
bus
Numberi2c bus the sensor is attached to.
-
address
NumberDevice address. Default is 0x18.
Returns:
name
()
String
Returns the name of the sensor
Returns:
getTemp
()
Number
Returns current temperature.
Returns:
shutDown
-
sleep
Will cause the devices to either sleep or wakeup.
Parameters:
-
sleep
BooleanBool, default true to sleep. false to wake.
setMode
-
celsius
setMode - sets temperature reporting mode.
Parameters:
-
celsius
BooleanDefault is true. If false all temps will be reported in fahrenheit.
isCelsius
()
Boolean
Returns true if mode is celsius False if fahrenheit.
Returns:
isTcrit
()
Boolean
Returns true if TCrit threshold has been crossed Reflects the state of the bit based on the most recent readTemp() operation.
Returns:
isTupper
()
Boolean
Returns true if TUpper threshold crossed Reflects the state of the bit based on the most recent readTemp() operation.
Returns:
isTlower
()
Boolean
Returns true if TLower threshold crossed. Reflects the state of the bit based on the most recent readTemp() operation.
Returns:
setMonitorReg
-
reg
-
value
Sets the value of TCrit, TUpper,TLower registers.
reg - MCP9808_REG enum UPPER_TEMP, LOWER_TEMP or CRIT_TEMP.
Parameters:
-
reg
MCP9808_REGundefined
-
value
Number- float value representing the set value
getMonitorReg
-
reg
Returns the current value of TCrit, TUpper, TLower registers.
Parameters:
-
reg
MCP9808_REG- MCP9808_REG enum UPPER_TEMP, LOWER_TEMP or CRIT_TEMP.
Returns:
clearInterrupt
()
Clears the interrupt when ALERT_MODE is set to interrupt output and temp threshold crossed.
setAlertMode
-
command
Sets alert mode. Can use values from MCP9808_CONFIG enum. Values can be combined.
Parameters:
-
command
Number- a combination of options to set desired alert mode. See spcec sheet.
clearAlertMode
()
Clears Alert Mode b sets all params to default.
setHysteresis
-
value
Sets hysteresis value.
Parameters:
-
value
MCP9808_CONFIGMCP9808_CONFIG enum value HYST_0, HYST_1_5, HYST_3_0 or HYST_6_0
getHysteresis
()
Number
Returns hysteresis setting as a float value.
Returns:
setResolution
-
value
Sets resolution of temperature conversion.
Parameters:
-
value
MCP9808_RESOLUTION- MCP9808_RESOLUTION enum value. RES_LOW = +0.5 C RES_MEDIUM = +0.25 C RES_HIGH = +0.125 C RES_PRECISION = +0.0625 C (default).
getResolution
()
Number
Returns float value representing the current resolution setting.
Returns:
getManufacturer
()
Number
Returns Manufacturer ID. Typically 0x0054;
Returns:
getDevicedId
()
Number
Returns device ID and revision. Typically 0x0400 With ID in the High byte.