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
clearAlertMode()[source]

void clearAlertMode(void)

Clears Alert Mode sets all params to default.

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.

getHysteresis()[source]

float getHysteresis()

Returns hysteresis setting as a float value.

getManufacturer()[source]

uint16_t getManufacturer()

Returns Manufacturer ID. Typically 0x0054;

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.

getTemp()[source]

float getTemp(void)

Returns current temperature.

isCelsius()[source]

bool isCelsius(void)

Returns true if mode is celsius False if fahrenheit.

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.

name()[source]

std::string name()

Returns the name of the sensor

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

setResolution(value)[source]

void setResolution(MCP9808_RESOLUTION value)

Sets resolution of temperature conversion.

value: - 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).

shutDown(sleep=True)[source]

void shutDown(bool sleep=true)

Will cause the devices to either sleep or wakeup.

sleep: Bool, default true to sleep. false to wake.