pyupm_mcp9808 module¶
-
class
pyupm_mcp9808.
MCP9808
(bus, address=24)[source]¶ Bases:
object
API for MCP9808 precision temprature sensor.
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.
C++ includes: mcp9808.hpp
-
ALERTCTRL
= 2048¶
-
ALERTMODE
= 256¶
-
ALERTPOL
= 512¶
-
ALERTSEL
= 1024¶
-
ALERTSTAT
= 4096¶
-
CRIT_TEMP
= 4¶
-
HYST_0
= 0¶
-
HYST_1_5
= 2¶
-
HYST_3_0
= 4¶
-
HYST_6_0
= 6¶
-
LOWER_TEMP
= 3¶
-
RES_HIGH
= 2¶
-
RES_LOW
= 0¶
-
RES_MEDIUM
= 1¶
-
RES_PRECISION
= 3¶
-
UPPER_TEMP
= 2¶
-
clearInterrupt
()[source]¶ void clearInterrupt(void)
Clears the interrupt when ALERT_MODE is set to interrupt output and temp threshold crossed.
-
getDevicedId
()[source]¶ uint16_t getDevicedId()
Returns device ID and revision. Typically 0x0400 With ID in the High byte.
-
getMonitorReg
(reg)[source]¶ float getMonitorReg(MCP9808_REG reg)
Returns the current value of TCrit, TUpper, TLower registers.
reg: - MCP9808_REG enum UPPER_TEMP, LOWER_TEMP or CRIT_TEMP.
-
getResolution
()[source]¶ float getResolution()
Returns float value representing the current resolution setting.
-
isTcrit
()[source]¶ bool isTcrit()
Returns true if TCrit threshold has been crossed Reflects the state of the bit based on the most recent readTemp() operation.
-
isTlower
()[source]¶ bool isTlower()
Returns true if TLower threshold crossed. Reflects the state of the bit based on the most recent readTemp() operation.
-
isTupper
()[source]¶ bool isTupper()
Returns true if TUpper threshold crossed Reflects the state of the bit based on the most recent readTemp() operation.
-
setAlertMode
(command)[source]¶ void setAlertMode(uint16_t command)
Sets alert mode. Can use values from MCP9808_CONFIG enum. Values can be combined.
command: - a combination of options to set desired alert mode. See spcec sheet.
-
setHysteresis
(value)[source]¶ void setHysteresis(MCP9808_CONFIG value)
Sets hysteresis value.
value: MCP9808_CONFIG enum value HYST_0, HYST_1_5, HYST_3_0 or HYST_6_0
-
setMode
(celsius=True)[source]¶ void setMode(bool celsius=true)
setMode - sets temperature reporting mode.
celsius: Default is true. If false all temps will be reported in fahrenheit.
-
setMonitorReg
(reg, value)[source]¶ void setMonitorReg(MCP9808_REG reg, float value)
Sets the value of TCrit, TUpper,TLower registers.
reg - MCP9808_REG enum UPPER_TEMP, LOWER_TEMP or CRIT_TEMP.
value: - float value representing the set value
-